|
YAACC - UPNP Client and Server
|
Counts the started browser activities of the process and arms an idle timer only when the count drops to zero. More...

Classes | |
| interface | Scheduler |
| Delayed execution on the main thread. More... | |
Public Member Functions | |
| StartedBrowserCounter (Scheduler scheduler, long timeoutMillis, Runnable onIdle) | |
| synchronized void | onBrowserStarted () |
A browser activity reached onStart. | |
| synchronized void | onBrowserStopped () |
A browser activity reached onStop. | |
| synchronized int | startedCount () |
Counts the started browser activities of the process and arms an idle timer only when the count drops to zero.
Why a counter and not "arm in onStop, cancel in onResume": when the layout changes, the old browser's onStop runs after the new browser's onResume, so a timer armed there would never be cancelled. Rotation has the same shape. Plain Java (no Android imports) so it can be unit tested; the Android side supplies the Scheduler. Call from the main thread only; all methods are synchronized anyway so a stray caller cannot corrupt the count.
| de.yaacc.browser.StartedBrowserCounter.StartedBrowserCounter | ( | Scheduler | scheduler, |
| long | timeoutMillis, | ||
| Runnable | onIdle ) |
| scheduler | schedules and cancels the expiry task |
| timeoutMillis | time without a started browser before onIdle runs |
| onIdle | runs on expiry; must re-read the current state itself |
| synchronized void de.yaacc.browser.StartedBrowserCounter.onBrowserStopped | ( | ) |
A browser activity reached onStop.
A stop without a start is ignored.
Referenced by de.yaacc.browser.BackgroundIdleTimer.browserStopped().
