Skip to content

amlcurran/Batcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Batcher Library for Android

Batcher is a new library aimed at descreasing your apps' impact on the battery life of a device. Battery life is a big deal when it comes to users, and they may remove your app if they think it drains too much battery.

How does this library help?

Batcher helps by giving you a simple framework with which to batch expensive operations (e.g. file uploads) depending on factors such as battery life, connection type & simple timings.

The library works in a very simple way. The batch operation is triggered when any conditions you have set have been met. Batcher has been designed to be extended easily - the conditions can be anything you like! See Usage for examples in how to create your own conditions.

Usage

  1. Extend Batcher, providing the type of input you wish to perform the batch operation on.
  2. Override performOperation(List) to specify the operation you wish to batch.
  3. Add either a single ShotCondition, or a ShotCondition and a SwitchCondition, and away you go!

There are two base classes, ShotCondition and SwitchCondition, that can be extended to suit any conditions you want your batching to meet. A third, CacheListenerShotCondition, is available for conditions which require manipulation or reading of the cached input values. ShotCondition is suitable for overriding when your condition is infrequent or can be triggered by an enviromental change, such as going over a cache size limit or every X second. In contrast, SwitchConditions are used in more of a secondary role, to prevent a batch being triggered under certain conditions (e.g. Airplane mode).

The image below shows the typical lifecycle of a Batcher instance, and may be helpful diagnosing issues or adding new features.

Lifecycle image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages