Advertisement
joris

ChatActivity

Aug 4th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.67 KB | None | 0 0
  1. private void chatUserPic(String id) {
  2.         DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
  3.         Query query = reference.child( "Users" ).child( id );
  4.         query.addListenerForSingleValueEvent( new ValueEventListener() {
  5.             @Override
  6.             public void onDataChange(DataSnapshot dataSnapshot) {
  7.  
  8.                 if (dataSnapshot.exists()) {
  9.                     final String URL_PROFILE = dataSnapshot.child( "thumb_image" ).getValue().toString();
  10.                     Picasso.with( getApplication() )
  11.                             .load( URL_PROFILE )
  12.                             .networkPolicy( NetworkPolicy.OFFLINE )
  13.                             .placeholder( R.drawable.no_profile )
  14.                             .into( mProfileImage, new Callback() {
  15.                                 @Override
  16.                                 public void onSuccess() {
  17.  
  18.                                 }
  19.  
  20.                                 @Override
  21.                                 public void onError() {
  22.                                     Picasso.with( getApplication() )
  23.                                             .load( URL_PROFILE )
  24.                                             .placeholder( R.drawable.no_profile )
  25.                                             .into( mProfileImage );
  26.                                 }
  27.                             } );
  28.                 } else {
  29.                     String URL_PROFILE = "no_profile";
  30.                     Log.i( "PAUL", URL_PROFILE );
  31.                 }
  32.             }
  33.  
  34.             @Override
  35.             public void onCancelled(DatabaseError databaseError) {
  36.  
  37.             }
  38.         } );
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement