YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.share.PendingPick Class Reference

The one receiver pick that can be open at a time in a browser activity (the "Play on..." sheet), and what the sheet's answer does with it. More...

Collaboration diagram for de.yaacc.share.PendingPick:
Collaboration graph

Classes

interface  Callbacks
 What the owner of the pick wants done with the answer. More...
 
enum  Outcome
 What resolve / abandon did. More...
 

Public Member Functions

 PendingPick (Supplier< String > idSupplier)
 
synchronized String open (Callbacks newCallbacks)
 Opens a pick.
 
synchronized boolean isOpen (String pickId)
 
Outcome resolve (String pickId, boolean confirmed, Set< String > chosenIds)
 The sheet's answer.
 
Outcome abandon ()
 Cancels the open pick, if any (the activity is going away, the share timed out).
 

Static Public Member Functions

static PendingPick createDefault ()
 A holder whose ids are random UUIDs (a restored sheet of an earlier process cannot match).
 

Detailed Description

The one receiver pick that can be open at a time in a browser activity (the "Play on..." sheet), and what the sheet's answer does with it.

Plain Java, no android.*, so the rules are unit tested on the JVM; the activity keeps one instance in a field (the pending action is lost with the activity, accepted).

  • open stores the callbacks of the action and returns an id the sheet reports back. While a pick is open, another open is dropped (returns null) and never replaces it, so an answer can only ever start the action the user saw.
  • resolve with a confirm and at least one receiver closes the pick and runs Callbacks#onConfirmed once; a confirm without a receiver keeps the pick open and runs nothing; a cancel closes the pick and runs Callbacks#onCancelled once and never hands out the ticked ids. An id that is not the open pick's (stale, forged, repeated, after an abandon) changes nothing, so nothing is delivered twice. The decision itself is ReceiverPickResult#decide.
  • abandon (the activity goes away, the share timed out) cancels an open pick.

The state is cleared before a callback runs and callbacks run outside the lock, so an action may open the next pick and a throwing action cannot leave a pick open. Thread-safe.

Constructor & Destructor Documentation

◆ PendingPick()

de.yaacc.share.PendingPick.PendingPick ( Supplier< String > idSupplier)
Parameters
idSuppliermakes the ids of picks; a null or empty id refuses the pick

Referenced by de.yaacc.share.PendingPick.createDefault().

Here is the caller graph for this function:

Member Function Documentation

◆ isOpen()

synchronized boolean de.yaacc.share.PendingPick.isOpen ( String pickId)
Returns
true if pickId is the id of the open pick

Referenced by de.yaacc.share.PendingPick.resolve().

Here is the caller graph for this function:

◆ open()

synchronized String de.yaacc.share.PendingPick.open ( Callbacks newCallbacks)

Opens a pick.

Returns
the id the sheet must report back, or null (and nothing changes) if a pick is already open, the callbacks are null or no id could be made

◆ resolve()

Outcome de.yaacc.share.PendingPick.resolve ( String pickId,
boolean confirmed,
Set< String > chosenIds )

The sheet's answer.

Parameters
pickIdthe id open returned
confirmedtrue for the confirm button, false for a dismissal
chosenIdsthe receivers ticked, may be null
Here is the call graph for this function:

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