ValueEventListener

mail@pastecode.io avatar
unknown
java
a year ago
1.2 kB
16
Indexable
Never
private void getUserStatus() { 

			myRef.child(mAuth.getUid())
                .addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(@NonNull DataSnapshot snapshot) {

                    if (snapshot.exists()) {

                        Users users = snapshot.getValue(Users.class);

                        if (users.isStatus() != null) {

                            if (users.isStatus()) {

                                counter++;

                                Log.e(TAG, "onDataChange: its mean isStatus = true | (count)= " + counter);

                                 if (counter == 1) {
                                    DialogUtils.showAlertStatusDialog(mActivity);
                                    counter = 2;
                                 }
                            }
                        } else {
                            Log.e(TAG, "onDataChange: its mean isStatus = false | (count)= " + counter);
                        }
                    }
                }

                @Override
                public void onCancelled(@NonNull DatabaseError error) {

                }
             });
}