Search in sources :

Example 21 with ChildEventListener

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

Example 22 with ChildEventListener

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

Example 23 with ChildEventListener

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);
    }
}
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 24 with ChildEventListener

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);
    }
}
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 25 with ChildEventListener

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);
    }
}
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)

Aggregations

ChildEventListener (com.google.firebase.database.ChildEventListener)38 DataSnapshot (com.google.firebase.database.DataSnapshot)38 DatabaseError (com.google.firebase.database.DatabaseError)38 DatabaseReference (com.google.firebase.database.DatabaseReference)11 Intent (android.content.Intent)7 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 BrixxEventModel (com.manan.dev.ec2018app.Models.BrixxEventModel)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 HashMap (java.util.HashMap)3 AlertDialog (android.support.v7.app.AlertDialog)2 Button (android.widget.Button)2 ImageView (android.widget.ImageView)2 RadioButton (android.widget.RadioButton)2