Search in sources :

Example 6 with DatabaseException

use of com.google.firebase.database.DatabaseException in project UniPool by divya21raj.

the class BaseActivity method getUserDetails.

protected void getUserDetails() {
    Globals.userDatabaseReference.addValueEventListener(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            // whenever data at this location is updated.
            try {
                if (dataSnapshot.getValue() != null) {
                    finalCurrentUser = dataSnapshot.getValue(User.class);
                    UtilityMethods.populateChatMap(dataSnapshot.child("pairUps"));
                    ReceivedRequestsFragment.refreshRecycler();
                    SentRequestsFragment.refreshRecycler();
                    ChatFragment.refreshRecycler();
                }
            } catch (DatabaseException dbe) {
                Toast.makeText(getApplicationContext(), "Some problems, mind restarting the app?", Toast.LENGTH_LONG).show();
            }
        }

        @Override
        public void onCancelled(DatabaseError error) {
            // Failed to read value
            Log.w("UserDB", "Failed to read userDB value.", error.toException());
            Toast.makeText(getApplicationContext(), "Network Issues!", Toast.LENGTH_SHORT).show();
        }
    });
    bottomNavigationView = findViewById(R.id.bottom_navigation);
    bottomNavigationView.setOnNavigationItemSelectedListener(this);
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) ValueEventListener(com.google.firebase.database.ValueEventListener) DataSnapshot(com.google.firebase.database.DataSnapshot) DatabaseException(com.google.firebase.database.DatabaseException)

Aggregations

DatabaseException (com.google.firebase.database.DatabaseException)6 DataSnapshot (com.google.firebase.database.DataSnapshot)4 DatabaseError (com.google.firebase.database.DatabaseError)4 Dialog (android.app.Dialog)3 Context (android.content.Context)3 Intent (android.content.Intent)3 ColorDrawable (android.graphics.drawable.ColorDrawable)3 View (android.view.View)3 Button (android.widget.Button)3 ValueEventListener (com.google.firebase.database.ValueEventListener)3 AutoCompleteTextView (android.widget.AutoCompleteTextView)2 DialogInterface (android.content.DialogInterface)1 Bundle (android.os.Bundle)1 AlertDialog (android.support.v7.app.AlertDialog)1 DatePicker (android.widget.DatePicker)1 EditText (android.widget.EditText)1 TextView (android.widget.TextView)1 FirebaseUser (com.google.firebase.auth.FirebaseUser)1 ChildEventListener (com.google.firebase.database.ChildEventListener)1 FeedMessage (com.google.samples.apps.iosched.feed.data.FeedMessage)1