Search in sources :

Example 26 with ChildEventListener

use of com.google.firebase.database.ChildEventListener in project OnlineCanteen by josephgunawan97.

the class DeleteProductFragment 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()))
                    deleteAdapter.addProductList(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 27 with ChildEventListener

use of com.google.firebase.database.ChildEventListener in project OnlineCanteen by josephgunawan97.

the class UserProductListFragment method attachProductDatabaseListener.

// ----------------  FIREBASE CHILD EVENT LISTENER -----------------//
private void attachProductDatabaseListener() {
    if (productsEventListener == null) {
        productsEventListener = new ChildEventListener() {

            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                Product product = dataSnapshot.getValue(Product.class);
                userProductItemAdapter.addProduct(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) {
            }
        };
        productsQuery.addChildEventListener(productsEventListener);
    }
}
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 28 with ChildEventListener

use of com.google.firebase.database.ChildEventListener in project EC2018App by Manan-YMCA.

the class MyNotificationsActivity method attachDatabaseListener.

private void attachDatabaseListener() {
    if (mChildEventListener == null) {
        mChildEventListener = new ChildEventListener() {

            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                NotificationModel nm = dataSnapshot.getValue(NotificationModel.class);
                updateList(nm);
                progress.dismiss();
            }

            @Override
            public void onChildChanged(DataSnapshot dataSnapshot, String s) {
                try {
                    NotificationModel nm = dataSnapshot.getValue(NotificationModel.class);
                    updateList(nm);
                    progress.dismiss();
                } catch (Exception e) {
                    e.printStackTrace();
                    progress.dismiss();
                }
            }

            @Override
            public void onChildRemoved(DataSnapshot dataSnapshot) {
                NotificationModel nm = dataSnapshot.getValue(NotificationModel.class);
                allNotificationsArrayList.remove(nm);
                progress.dismiss();
            }

            @Override
            public void onChildMoved(DataSnapshot dataSnapshot, String s) {
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
                progress.dismiss();
            }
        };
        mDatabaseReference.addChildEventListener(mChildEventListener);
    }
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) DataSnapshot(com.google.firebase.database.DataSnapshot) NotificationModel(com.manan.dev.ec2018app.Models.NotificationModel) ChildEventListener(com.google.firebase.database.ChildEventListener)

Example 29 with ChildEventListener

use of com.google.firebase.database.ChildEventListener in project EC2018App by Manan-YMCA.

the class MrCulFragment method attachDatabaseListener.

private void attachDatabaseListener() {
    if (mChildEventListener == null) {
        mChildEventListener = new ChildEventListener() {

            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                if (dataSnapshot.getKey().equals("mrmsculmyca")) {
                    BrixxEventModel w = dataSnapshot.getValue(BrixxEventModel.class);
                    updateUI(w);
                }
            }

            @Override
            public void onChildChanged(DataSnapshot dataSnapshot, String s) {
                try {
                    if (dataSnapshot.getKey().equals("mrmsculmyca")) {
                        BrixxEventModel w = dataSnapshot.getValue(BrixxEventModel.class);
                        updateUI(w);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onChildRemoved(DataSnapshot dataSnapshot) {
            }

            @Override
            public void onChildMoved(DataSnapshot dataSnapshot, String s) {
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        };
        mDatabaseReference.addChildEventListener(mChildEventListener);
    }
}
Also used : BrixxEventModel(com.manan.dev.ec2018app.Models.BrixxEventModel) DatabaseError(com.google.firebase.database.DatabaseError) DataSnapshot(com.google.firebase.database.DataSnapshot) ChildEventListener(com.google.firebase.database.ChildEventListener)

Example 30 with ChildEventListener

use of com.google.firebase.database.ChildEventListener in project EC2018App by Manan-YMCA.

the class RangritiFragment method attachDatabaseListener.

private void attachDatabaseListener() {
    if (mChildEventListener == null) {
        mChildEventListener = new ChildEventListener() {

            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                if (dataSnapshot.getKey().equals("rangriti")) {
                    BrixxEventModel w = dataSnapshot.getValue(BrixxEventModel.class);
                    updateUI(w);
                }
            }

            @Override
            public void onChildChanged(DataSnapshot dataSnapshot, String s) {
                try {
                    if (dataSnapshot.getKey().equals("rangriti")) {
                        BrixxEventModel w = dataSnapshot.getValue(BrixxEventModel.class);
                        updateUI(w);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onChildRemoved(DataSnapshot dataSnapshot) {
            }

            @Override
            public void onChildMoved(DataSnapshot dataSnapshot, String s) {
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        };
        mDatabaseReference.addChildEventListener(mChildEventListener);
    }
}
Also used : BrixxEventModel(com.manan.dev.ec2018app.Models.BrixxEventModel) DatabaseError(com.google.firebase.database.DatabaseError) 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