Tweakr
Android Library for Remote Debugging, Autogenerating Settings/Preference UIs, and Wizard-of-Ozing
com.google.tweakr.TweakrFirebaseRepo Class Reference
Inheritance diagram for com.google.tweakr.TweakrFirebaseRepo:
com.google.tweakr.TweakrRepo com.google.tweakr.TweakrFirebaseRepoMultiuser

Public Member Functions

CompletableFuture< String > getUserKey ()
 
void addListener (OnChangeListener listener)
 
void removeListener (OnChangeListener listener)
 
void add (String name, int targetId, ValueType valueType, Object initialValue, TweakMetadata tweakMetadata)
 
void addListener (OnChangeListener listener)
 
void removeListener (OnChangeListener listener)
 
void add (String name, int targetId, ValueType valueType, Object initialValue, TweakMetadata tweakMetadata)
 

Protected Member Functions

CompletableFuture< Boolean > authenticate ()
 
FirebaseDatabase getDatabase ()
 
String getRootCollectionKey ()
 

Static Protected Attributes

static final String TAG = "TweakrRepo"
 

Additional Inherited Members

- Public Attributes inherited from com.google.tweakr.TweakrRepo
String FIELD_SEPARATOR = ":"
 

Detailed Description

A TweakrRepo that uses Firebase to store and manipulate values with a Web UI.

Member Function Documentation

◆ add()

void com.google.tweakr.TweakrFirebaseRepo.add ( String  name,
int  targetId,
ValueType  valueType,
Object  initialValue,
TweakMetadata  tweakMetadata 
)

Add a new Tweak.

Parameters
namefully-qualified name of the tweak: may be a path of parent objects to the actual field's name, separated by FIELD_SEPARATOR.
targetIdmonotonically increasing ID of the target object.
valueTypeValueType for converting the UI value before passing it to OnChangeListener#onFieldChanged.
initialValueInitial value of the field as it exists in the target object.
tweakMetadataMetadata from the annotation for the UI to display.

Implements com.google.tweakr.TweakrRepo.

◆ addListener()

void com.google.tweakr.TweakrFirebaseRepo.addListener ( OnChangeListener  listener)

Registers a listener to be notified whenever a value changes in the UI.

Implements com.google.tweakr.TweakrRepo.

◆ authenticate()

CompletableFuture< Boolean > com.google.tweakr.TweakrFirebaseRepo.authenticate ( )
protected

Authenticates with Firebase before adding any Tweaks.

This will be called repeatedly so you should cache by checking FirebaseAuth.getCurrentUser(), and simply returning that if it already exists.

If your database allows anonymous users and does not require authentication, you may simply return a Future that resolves to null. This is the default behavior.

Returns
A Future which completes once the user has logged in. Once it completes, any Tweaks queued up will be added immediately.

◆ getDatabase()

FirebaseDatabase com.google.tweakr.TweakrFirebaseRepo.getDatabase ( )
protected

Returns the Firebase database to use. You may override this if you would like to use multiple Firebase instances in your app.

◆ getRootCollectionKey()

String com.google.tweakr.TweakrFirebaseRepo.getRootCollectionKey ( )
protected

Returns the name of the root-level collection in the database to add all Tweaks.

Override this if you are using the same database for multiple apps.

◆ getUserKey()

CompletableFuture< String > com.google.tweakr.TweakrFirebaseRepo.getUserKey ( )

Returns the user's sub-collection key. Use this if you want each user to be able to Tweak their own set of values, which will not change the other users' values.

Returns
an alphanumeric identifier that is unique per user.

Reimplemented in com.google.tweakr.TweakrFirebaseRepoMultiuser.

◆ removeListener()

void com.google.tweakr.TweakrFirebaseRepo.removeListener ( OnChangeListener  listener)

Removes a listener added with addListener(OnChangeListener)

Implements com.google.tweakr.TweakrRepo.


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