Search in sources :

Example 1 with ChildEventListener

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);
    }
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) Product(com.example.asus.onlinecanteen.model.Product) DataSnapshot(com.google.firebase.database.DataSnapshot) ArrayAdapter(android.widget.ArrayAdapter) ChildEventListener(com.google.firebase.database.ChildEventListener)

Example 2 with ChildEventListener

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);
    }
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) Product(com.example.asus.onlinecanteen.model.Product) DataSnapshot(com.google.firebase.database.DataSnapshot) ChildEventListener(com.google.firebase.database.ChildEventListener)

Example 3 with ChildEventListener

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);
    }
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) Store(com.example.asus.onlinecanteen.model.Store) DataSnapshot(com.google.firebase.database.DataSnapshot) ChildEventListener(com.google.firebase.database.ChildEventListener)

Example 4 with ChildEventListener

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);
    }
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) Transaction(com.example.asus.onlinecanteen.model.Transaction) DataSnapshot(com.google.firebase.database.DataSnapshot) ChildEventListener(com.google.firebase.database.ChildEventListener)

Example 5 with ChildEventListener

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);
    }
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) DataSnapshot(com.google.firebase.database.DataSnapshot) SalesReport(com.example.asus.onlinecanteen.model.SalesReport) ChildEventListener(com.google.firebase.database.ChildEventListener)

Aggregations

ChildEventListener (com.google.firebase.database.ChildEventListener)39 DataSnapshot (com.google.firebase.database.DataSnapshot)39 DatabaseError (com.google.firebase.database.DatabaseError)39 DatabaseReference (com.google.firebase.database.DatabaseReference)11 Intent (android.content.Intent)8 View (android.view.View)5 Product (com.example.asus.onlinecanteen.model.Product)5 Map (java.util.Map)5 ListView (android.widget.ListView)4 FirebaseDatabase (com.google.firebase.database.FirebaseDatabase)4 TextView (android.widget.TextView)3 Transaction (com.example.asus.onlinecanteen.model.Transaction)3 LatLng (com.google.android.gms.maps.model.LatLng)3 Query (com.google.firebase.database.Query)3 ValueEventListener (com.google.firebase.database.ValueEventListener)3 BrixxEventModel (com.manan.dev.ec2018app.Models.BrixxEventModel)3 HashMap (java.util.HashMap)3 AlertDialog (android.support.v7.app.AlertDialog)2 Button (android.widget.Button)2 ImageView (android.widget.ImageView)2