use of com.google.firebase.database.ChildEventListener in project OnlineCanteen by josephgunawan97.
the class MainUserActivity method onStart.
@Override
protected void onStart() {
super.onStart();
userEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
if (dataSnapshot.getKey().equals(user.getUid())) {
User currentUser = dataSnapshot.getValue(User.class);
AccountUtil.setCurrentAccount(currentUser);
populateUserInfo();
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
if (userReference != null)
userReference.addChildEventListener(userEventListener);
}
use of com.google.firebase.database.ChildEventListener in project OnlineCanteen by josephgunawan97.
the class AdminConfirmTopUpActivity method attachDatabaseReadListener.
private void attachDatabaseReadListener() {
if (EventListener == null) {
EventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
TopUp topUp = dataSnapshot.getValue(TopUp.class);
Log.i(AdminConfirmTopUpActivity.class.getSimpleName(), "TES LOG " + topUp.getUid());
adapter.addTopUp(topUp);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
TopUpUtil.query().addChildEventListener(EventListener);
}
}
use of com.google.firebase.database.ChildEventListener in project OnlineCanteen by josephgunawan97.
the class MerchantOrderListFragment method attachDatabaseReadListener.
private void attachDatabaseReadListener() {
if (eventListener == null) {
eventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Transaction newTransaction = dataSnapshot.getValue(Transaction.class);
if (merchant.getUid().equals(newTransaction.getSid()))
adapter.add(newTransaction);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
Transaction newTransaction = dataSnapshot.getValue(Transaction.class);
if (merchant.getUid().equals(newTransaction.getSid()))
adapter.add(newTransaction);
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
databaseTransaction.addChildEventListener(eventListener);
}
}
use of com.google.firebase.database.ChildEventListener in project OnlineCanteen by josephgunawan97.
the class MerchantProductListFragment method attachDatabaseReadListener.
private void attachDatabaseReadListener() {
if (productEventListener == null) {
productEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Product product = dataSnapshot.getValue(Product.class);
if (merchant.getUid().equals(product.getTokoId()))
menuListAdapter.add(product);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
Product product = dataSnapshot.getValue(Product.class);
if (merchant.getUid().equals(product.getTokoId()))
menuListAdapter.add(product);
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
databaseProducts.addChildEventListener(productEventListener);
}
}
use of com.google.firebase.database.ChildEventListener in project OnlineCanteen by josephgunawan97.
the class TransactionCurrentOrderFragment method attachTransactionEventListener.
private void attachTransactionEventListener() {
if (transactionEventListener == null) {
transactionEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Transaction newTransaction = dataSnapshot.getValue(Transaction.class);
if (newTransaction.getDeliveryStatus() < 3)
adapter.addTransactionHistory(newTransaction);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
transactionQuery.addChildEventListener(transactionEventListener);
}
}
Aggregations