public interface QuotaManager


Interface responsible for managing quota. Before initiating some action (e.g. starting an animation) that uses a limited resource, tryAcquireQuota should be called to see if the target quota cap has been reached and if not, it will be updated. When action/resource is finished, it should be release with releaseQuota.

For example, this can be used for limiting the number of concurrently running animations. Every time new animations is due to be played, it should request quota from QuotaManager in amount that is equal to the number of animations that should be played (e.g. playing fade in and slide in animation on one object should request amount of 2 quota.

It is callers responsibility to release acquired quota after limited resource has been finished. For example, when animation is running, but surface became invisible, caller should return acquired quota.

Summary

Public methods

abstract void
releaseQuota(int quota)

Releases the given amount of quota.

abstract boolean
tryAcquireQuota(int quota)

Tries to acquire the given amount of quota and returns true if successful.

Public methods

releaseQuota

Added in 1.0.0
abstract void releaseQuota(int quota)

Releases the given amount of quota.

Throws
java.lang.IllegalArgumentException

if the given quota amount exceeds the amount of acquired quota.

tryAcquireQuota

Added in 1.0.0
abstract boolean tryAcquireQuota(int quota)

Tries to acquire the given amount of quota and returns true if successful. Otherwise, returns false meaning that quota cap has already been reached and the quota won't be acquired.

It is callers responsibility to release acquired quota after limited resource has been finished. For example, when animation is running, but surface became invisible, caller should return acquired quota.