Skip to content

Instantly share code, notes, and snippets.

@motorro
Last active October 10, 2020 10:20
Show Gist options
  • Save motorro/b491e08457cd5aa9d4706002745c7710 to your computer and use it in GitHub Desktop.
Save motorro/b491e08457cd5aa9d4706002745c7710 to your computer and use it in GitHub Desktop.
Update flow breaker
/**
* Checks if user has already refused to install update and terminates update flow
*/
interface UpdateFlowBreaker: TimeCancelledStorage {
/**
* Checks if enough time has passed since user had explicitly cancelled update
*/
fun isEnoughTimePassedSinceLatestCancel(): Boolean
/**
* An extra point to check if update available is of any value to user
* For example you may implement extra logic on update priority level (set from play market) or
* staleness. Called _instead_ of [isEnoughTimePassedSinceLatestCancel] when processing
* available update so you may want to combine both time of last offer and update value at the
* same time.
* @param updateInfo
*/
fun isUpdateValuable(updateInfo: AppUpdateInfo): Boolean
}
/**
* Stores time the update was cancelled
*/
interface TimeCancelledStorage {
/**
* Gets the latest time user has explicitly cancelled update (in milliseconds)
*/
fun getTimeCanceled(): Long
/**
* Saves current time as the latest one user has explicitly cancelled update
*/
fun saveTimeCanceled()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment