@Override public void onDataChange(DataSnapshot dataSnapshot) { UserData u = dataSnapshot.getValue(UserData.class); if (mCurrentUser == null) { mCurrentUser = new UserWrapper(mUid, u); } else { mCurrentUser.setId(mUid); mCurrentUser.setData(u); } checkResult(true, mResultListener); }
@Override public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot.getValue() != null) { UserWrapper userWrapper = new UserWrapper(); userWrapper.setId(dataSnapshot.getKey()); userWrapper.setData(dataSnapshot.getValue(UserData.class)); mValueListener.onFinish(); mValueListener.onSuccess(new UserWrapper[] {userWrapper}); } else { Log.i(TAG, "user not found " + dataSnapshot.getKey()); onCancelled(new FirebaseError(96, "user not found : " + dataSnapshot.getKey())); } }
@JsonIgnore public static void getUser(String uid, RibbitValueListener<UserWrapper> valueListener) { if ((uid != null) && (uid.length() != mCurrentUser.getId().length())) { throw new IllegalStateException("requested user id not valid : " + uid); } Firebase firebase = RibbitUser.getFirebaseUsers().child("/" + uid); firebase.addListenerForSingleValueEvent(new UserValueListener(valueListener)); }