Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private StorageReference storageReference;
- //path where images of user profile and cover will be stored
- private String storagePath = "Users_Profile_Cover_Images/";
- //permission constants
- private static final int CAMERA_REQUEST_CODE = 100;
- private static final int STORAGE_REQUEST_CODE = 200;
- private static final int IMAGE_PICK_CAMERA_CODE = 400;
- //arrays of permissions to be requested
- private String[] cameraPermission;
- private String[] storageaPermission;
- //uri of picked images
- private Uri image_uri;
- //for checking profile or cover photo
- private String profileOrCoverPhoto;
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable
- ViewGroup container, @Nullable Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- View view = inflater.inflate(R.layout.activity_profile, container,
- false);
- //init arrays of permissions
- cameraPermission = new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE};
- storageaPermission = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
- //init views
- avatarIv = view.findViewById(R.id.profileIv);
- Query query = databaseReference.orderByChild("email").equalTo(user.getEmail());
- query.addValueEventListener(new ValueEventListener() {
- @Override
- public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
- for (DataSnapshot ds : dataSnapshot.getChildren()) {
- //get data
- String email = "" + ds.child("email").getValue();
- String image = "" + ds.child("image").getValue();
- try {
- Picasso.get().load(image).fit().into(avatarIv);
- }
- catch (Exception e)
- {
- Picasso.get().load(R.drawable.ic_people).into(avatarIv);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement