use of com.google.samples.apps.iosched.feed.data.FeedMessage in project iosched by google.
the class FeedPresenter method initializeDataListener.
@Override
public void initializeDataListener(DatabaseReference databaseReference) {
if (mEventListener == null) {
mEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
try {
FeedMessage feedMessage = dataSnapshot.getValue(FeedMessage.class);
mView.addFeedMessage(feedMessage);
} catch (DatabaseException e) {
mView.showErrorMessage();
LOGE(TAG, "Firebase error - " + e);
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
try {
FeedMessage feedMessage = dataSnapshot.getValue(FeedMessage.class);
mView.updateFeedMessage(feedMessage);
} catch (DatabaseException e) {
mView.showErrorMessage();
LOGE(TAG, "Firebase error - " + e);
}
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
try {
FeedMessage feedMessage = dataSnapshot.getValue(FeedMessage.class);
mView.removeFeedMessage(feedMessage);
} catch (DatabaseException e) {
mView.showErrorMessage();
LOGE(TAG, "Firebase error - " + e);
}
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
try {
FeedMessage feedMessage = dataSnapshot.getValue(FeedMessage.class);
mView.updateFeedMessage(feedMessage);
} catch (DatabaseException e) {
mView.showErrorMessage();
LOGE(TAG, "Firebase error - " + e);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
mView.showErrorMessage();
}
};
}
databaseReference.addChildEventListener(mEventListener);
}
Aggregations