public class GdxFIRDatabase extends PlatformDistributor<DatabaseDistribution> implements DatabaseDistribution
DatabaseDistribution,
PlatformDistributorplatformObject| Modifier | Constructor and Description |
|---|---|
protected |
GdxFIRDatabase()
GdxFIRDatabase protected constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
getAndroidClassName()
Gives class name of object that will be create when application running on android platform.
|
protected java.lang.String |
getIOSClassName()
Gives class name of object that will be create when application running on ios platform.
|
DatabaseDistribution |
inReference(java.lang.String databasePath)
Sets database path you want to deal with in next action.
|
static GdxFIRDatabase |
instance() |
void |
keepSynced(boolean synced)
Keeps data fresh.
|
void |
onConnect(ConnectedListener connectedListener)
Listens for database connection events.
|
<T,E extends T> |
onDataChange(java.lang.Class<T> dataType,
DataChangeListener<E> listener)
Handles value changes for path given by
inReference(String) and gives response by DataChangeListener. |
DatabaseDistribution |
push()
Creates new object inside database and return
this instance with reference to it set by DatabaseDistribution#inReference()
Remember to set database reference earlier by calling the DatabaseDistribution.inReference(String) method. |
<T,E extends T> |
readValue(java.lang.Class<T> dataType,
DataCallback<E> callback)
Reads value from path given by
inReference(String) and gives response by DataCallback. |
void |
removeValue()
Removes value in path given by
inReference(String). |
void |
removeValue(CompleteCallback completeCallback)
Removes value for path given by
inReference(String) and gives response by DataChangeListener. |
void |
setPersistenceEnabled(boolean enabled)
Keeps your data for offline usage.
|
void |
setValue(java.lang.Object value)
Sets value for path given by
inReference(String). |
void |
setValue(java.lang.Object value,
CompleteCallback completeCallback)
Sets value for path given by
inReference(String) and gives response by CompleteCallback. |
<T,R extends T> |
transaction(java.lang.Class<T> dataType,
TransactionCallback<R> transactionCallback,
CompleteCallback completeCallback)
Provides transaction for value describe by path given by
inReference(String) and gives response by CompleteCallback
Value that you want to change will be get in TransactionCallback.run(Object) - there you should
modifying data and returns a new one. |
void |
updateChildren(java.util.Map<java.lang.String,java.lang.Object> data)
Updates children's for path given by
inReference(String). |
void |
updateChildren(java.util.Map<java.lang.String,java.lang.Object> data,
CompleteCallback completeCallback)
Updates children's for path given by
inReference(String) and gives response by CompleteCallback. |
setMockObjectprotected GdxFIRDatabase()
throws PlatformDistributorException
Instance of this class should be getting by instance()
PlatformDistributorExceptionpublic static GdxFIRDatabase instance()
public void onConnect(ConnectedListener connectedListener)
Catch moment when application is going to to be connected or disconnected to the database.
onConnect in interface DatabaseDistributionconnectedListener - Listener that handles moments when connection status into database was changepublic DatabaseDistribution inReference(java.lang.String databasePath)
inReference in interface DatabaseDistributiondatabasePath - Reference inside your database for ex. "/users"public void setValue(java.lang.Object value)
inReference(String).setValue in interface DatabaseDistributionvalue - Any value which you want to store. Given object will be transformed to Firebase-like data type.public void setValue(java.lang.Object value,
CompleteCallback completeCallback)
inReference(String) and gives response by CompleteCallback.setValue in interface DatabaseDistributionvalue - Any value which you want to store. Given object will be transformed to Firebase-like data type.completeCallback - Callback that handles responseCompleteCallbackpublic <T,E extends T> void readValue(java.lang.Class<T> dataType,
DataCallback<E> callback)
inReference(String) and gives response by DataCallback.readValue in interface DatabaseDistributionT - Type of data you want to retrieve, associated with dataType for ex. List.classE - More specific type of data you want to retrieve associated with callback - needed because of nested generic types for ex. List<User>dataType - Class you want to retrievecallback - Callback that handles responseDataCallbackpublic <T,E extends T> void onDataChange(java.lang.Class<T> dataType,
DataChangeListener<E> listener)
DatabaseDistributioninReference(String) and gives response by DataChangeListener.
Remember to set database reference earlier by calling the DatabaseDistribution.inReference(String) method.
onDataChange in interface DatabaseDistributionT - Type of data you want to retrieve, associated with dataType for ex. List.classE - More specific type of data you want to retrieve associated with listener - needed because of nested generic types for ex. List<User>dataType - Class you want to retrievelistener - Listener, may by null - if null all listeners for specified database reference will be removed.DataChangeListenerpublic DatabaseDistribution push()
this instance with reference to it set by DatabaseDistribution#inReference()
Remember to set database reference earlier by calling the DatabaseDistribution.inReference(String) method.
push in interface DatabaseDistributionpublic void removeValue()
inReference(String).
Remember to set database reference earlier by calling the DatabaseDistribution.inReference(String) method.
removeValue in interface DatabaseDistributionpublic void removeValue(CompleteCallback completeCallback)
inReference(String) and gives response by DataChangeListener.
Remember to set database reference earlier by calling the DatabaseDistribution.inReference(String) method.
removeValue in interface DatabaseDistributioncompleteCallback - Complete callbackCompleteCallbackpublic void updateChildren(java.util.Map<java.lang.String,java.lang.Object> data)
inReference(String).
Remember to set database reference earlier by calling the DatabaseDistribution.inReference(String) method.
updateChildren in interface DatabaseDistributiondata - New datapublic void updateChildren(java.util.Map<java.lang.String,java.lang.Object> data,
CompleteCallback completeCallback)
inReference(String) and gives response by CompleteCallback.
Remember to set database reference earlier by calling the DatabaseDistribution.inReference(String) method.
updateChildren in interface DatabaseDistributiondata - New datacompleteCallback - Callback when donepublic <T,R extends T> void transaction(java.lang.Class<T> dataType,
TransactionCallback<R> transactionCallback,
CompleteCallback completeCallback)
inReference(String) and gives response by CompleteCallback
Value that you want to change will be get in TransactionCallback.run(Object) - there you should
modifying data and returns a new one.
Remember to set database reference earlier by calling the DatabaseDistribution.inReference(String) method.
transaction in interface DatabaseDistributiondataType - Type of data you want to get.transactionCallback - Callback called when transaction is complete.completeCallback - Can be nullCompleteCallback,
TransactionCallbackpublic void setPersistenceEnabled(boolean enabled)
setPersistenceEnabled in interface DatabaseDistributionenabled - epublic void keepSynced(boolean synced)
You can read more here and here
Remember to set database reference earlier by calling the DatabaseDistribution.inReference(String) method.
keepSynced in interface DatabaseDistributionsynced - If true sync for specified database path will be enabledprotected java.lang.String getIOSClassName()
getIOSClassName in class PlatformDistributor<DatabaseDistribution>protected java.lang.String getAndroidClassName()
getAndroidClassName in class PlatformDistributor<DatabaseDistribution>