use of com.supercilex.robotscouter.util.DatabaseHelper.ChangeEventListenerBase in project Robot-Scouter by SUPERCILEX.
the class AppIndexingService method onDataChange.
@Override
public void onDataChange(DataSnapshot snapshot) {
long numOfExpectedTeams = snapshot.getChildrenCount();
if (numOfExpectedTeams == 0) {
FirebaseAppIndex.getInstance().update();
return;
}
Constants.sFirebaseTeams.addChangeEventListener(new ChangeEventListenerBase() {
@Override
public void onChildChanged(EventType type, DataSnapshot snapshot, int index, int oldIndex) {
if (type == EventType.ADDED) {
mIndexables.add(Constants.sFirebaseTeams.getObject(index).getHelper().getIndexable());
}
if (mIndexables.size() >= numOfExpectedTeams) {
FirebaseAppIndex.getInstance().update(mIndexables.toArray(new Indexable[mIndexables.size()]));
Constants.sFirebaseTeams.removeChangeEventListener(this);
}
}
});
}
Aggregations