use of com.google.firebase.database.ChildEventListener in project OnlineCanteen by josephgunawan97.
the class EditProductActivity method getProduct.
public void getProduct() {
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())) {
productArrayList.add(product.getName().toString());
}
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_item, productArrayList);
spinner.setAdapter(dataAdapter);
}
@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) {
}
};
databaseProducts.addChildEventListener(productEventListener);
}
}
use of com.google.firebase.database.ChildEventListener in project OnlineCanteen by josephgunawan97.
the class MainActivity 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);
menuListAdapter.add(product);
}
@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) {
}
};
databaseProducts.addChildEventListener(productEventListener);
}
}
use of com.google.firebase.database.ChildEventListener in project OnlineCanteen by josephgunawan97.
the class MainUserFragment method attachStoreDatabaseListener.
// ---------------- FIREBASE CHILD EVENT LISTENER -----------------//
private void attachStoreDatabaseListener() {
if (storesEventListener == null) {
storesEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Store store = dataSnapshot.getValue(Store.class);
store.setStoreId(dataSnapshot.getKey());
userStoreAdapter.addStore(store);
}
@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) {
}
};
storesQuery.addChildEventListener(storesEventListener);
}
}
use of com.google.firebase.database.ChildEventListener in project OnlineCanteen by josephgunawan97.
the class TransactionHistoryFragment 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);
}
}
use of com.google.firebase.database.ChildEventListener in project OnlineCanteen by josephgunawan97.
the class AdminSalesReportsListActivity method attachDatabaseReadListener.
private void attachDatabaseReadListener() {
if (EventListener == null) {
EventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
SalesReport salesReport = dataSnapshot.getValue(SalesReport.class);
adapter.addSalesReport(salesReport);
}
@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) {
}
};
SalesReportUtil.query().addChildEventListener(EventListener);
}
}
Aggregations