public class KeyManager
extends java.lang.Object
implements android.arch.lifecycle.LifecycleObserver
KeyManager class collects all of the use cases related to key management. Key
management includes saving keys, fetching keys, and using keys for physical access. All of these
methods will be executed on a background thread and will return the result on the main thread.
To receive the result, a SingleCallback or CompleteCallback must be provided.
To save keys, call save(List, int, SingleCallback) to save the List of
KeyEntity objects to the server by badge ID. The keys can then be fetched by calling
list(int, SingleCallback) or list(int, boolean, SingleCallback) and providing
the badge ID and optional parameter for a force refresh, depending on whether or not the keys
should be retrieved from the cache or from the server.
To use a key for physical access, call access(KeyParam, SingleCallback) and provide a
valid KeyParam object.
| Constructor and Description |
|---|
KeyManager(android.support.v7.app.AppCompatActivity appCompatActivity)
Constructor for an
KeyManager object with the lifecycle set. |
KeyManager(android.support.v4.app.Fragment fragment)
Constructor for an
KeyManager object with the lifecycle set. |
KeyManager(android.arch.lifecycle.Lifecycle lifecycle)
Constructor for an
KeyManager object with the lifecycle set. |
| Modifier and Type | Method and Description |
|---|---|
void |
access(KeyParam keyParam,
SingleCallback<PairEntity<java.lang.Boolean,java.lang.String>> callback)
Returns a
PairEntity object that includes the access success result and the name
of the key after attempting physical access. |
void |
list(int badgeId,
boolean forceRefresh,
SingleCallback<java.util.List<KeyEntity>> callback)
Returns the
List of KeyEntity objects for a badge. |
void |
list(int badgeId,
SingleCallback<java.util.List<KeyEntity>> callback)
Returns the
List of KeyEntity objects for a badge. |
void |
save(java.util.List<KeyEntity> param,
int badgeId,
SingleCallback<java.lang.Boolean> callback)
Returns a boolean that represents whether or not saving the
List of KeyEntity
objects to server was successful. |
public KeyManager(android.arch.lifecycle.Lifecycle lifecycle)
KeyManager object with the lifecycle set.lifecycle - See Lifecyclepublic KeyManager(android.support.v7.app.AppCompatActivity appCompatActivity)
KeyManager object with the lifecycle set.appCompatActivity - See AppCompatActivitypublic KeyManager(android.support.v4.app.Fragment fragment)
KeyManager object with the lifecycle set.fragment - See Fragmentpublic void save(java.util.List<KeyEntity> param, int badgeId, SingleCallback<java.lang.Boolean> callback)
List of KeyEntity
objects to server was successful.
XXX todo should not provide such method.public void list(int badgeId,
boolean forceRefresh,
SingleCallback<java.util.List<KeyEntity>> callback)
List of KeyEntity objects for a badge. May be retrieved from
the server or from the cache.public void list(int badgeId,
SingleCallback<java.util.List<KeyEntity>> callback)
List of KeyEntity objects for a badge. These will be retrieved
from the cache.badgeId - the identification number of the bagecallback - the callback to receive the List of KeyEntity objects for
a badgepublic void access(KeyParam keyParam, SingleCallback<PairEntity<java.lang.Boolean,java.lang.String>> callback)
PairEntity object that includes the access success result and the name
of the key after attempting physical access.keyParam - See KeyParamcallback - the callback to receive result of attempting physical access