Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. private StorageReference storageReference;
  2.  
  3. //path where images of user profile and cover will be stored
  4. private String storagePath = "Users_Profile_Cover_Images/";
  5.  
  6. //permission constants
  7. private static final int CAMERA_REQUEST_CODE = 100;
  8. private static final int STORAGE_REQUEST_CODE = 200;
  9. private static final int IMAGE_PICK_CAMERA_CODE = 400;
  10.  
  11. //arrays of permissions to be requested
  12. private String[] cameraPermission;
  13. private String[] storageaPermission;
  14.  
  15. //uri of picked images
  16. private Uri image_uri;
  17. //for checking profile or cover photo
  18. private String profileOrCoverPhoto;
  19.  
  20. public View onCreateView(@NonNull LayoutInflater inflater, @Nullable
  21. ViewGroup container, @Nullable Bundle savedInstanceState) {
  22. // Inflate the layout for this fragment
  23. View view = inflater.inflate(R.layout.activity_profile, container,
  24. false);
  25.  
  26. //init arrays of permissions
  27. cameraPermission = new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE};
  28. storageaPermission = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
  29.  
  30. //init views
  31. avatarIv = view.findViewById(R.id.profileIv);
  32.  
  33. Query query = databaseReference.orderByChild("email").equalTo(user.getEmail());
  34. query.addValueEventListener(new ValueEventListener() {
  35. @Override
  36. public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
  37.  
  38. for (DataSnapshot ds : dataSnapshot.getChildren()) {
  39. //get data
  40. String email = "" + ds.child("email").getValue();
  41. String image = "" + ds.child("image").getValue();
  42. try {
  43. Picasso.get().load(image).fit().into(avatarIv);
  44. }
  45. catch (Exception e)
  46. {
  47. Picasso.get().load(R.drawable.ic_people).into(avatarIv);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement