YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.browser.StartedBrowserCounter Class Reference

Counts the started browser activities of the process and arms an idle timer only when the count drops to zero. More...

Collaboration diagram for de.yaacc.browser.StartedBrowserCounter:
Collaboration graph

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 ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ StartedBrowserCounter()

de.yaacc.browser.StartedBrowserCounter.StartedBrowserCounter ( Scheduler scheduler,
long timeoutMillis,
Runnable onIdle )
Parameters
schedulerschedules and cancels the expiry task
timeoutMillistime without a started browser before onIdle runs
onIdleruns on expiry; must re-read the current state itself

Member Function Documentation

◆ onBrowserStopped()

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().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: