Hot questions for Using Glide in firebase


I am attempting to load images from firebase into a recycler adapter and display them

I have attempted two methods to try and solve this problem the first block of code resulted in the error"You cannot start a load on a not yet attached View or a Fragment where getActivity() returns null (which usually occurs when getActivity() is called before the Fragment is attached or after the Fragment is destroyed)"

The second method the application ran but no images were loaded from reading other similar issues I have seen the isAdded() check but I couldn't seem to get that to work the images are being uploaded into a folder in firebase called post_images and the rest of the data associated with the post (Instagram like app with posting) are in firestore

public BlogRecyclerAdapter(List<BlogPost> blog_list) {

    this.blog_list = blog_list;


public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.blog_list_item, parent, false);
    return new ViewHolder(view);

public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

    String desc_data = blog_list.get(position).getDesc();

    String image_url = blog_list.get(position).getImage_url();


public int getItemCount() {
    return blog_list.size();

public class ViewHolder extends RecyclerView.ViewHolder {

    private View mView;

    private TextView descView;
    private ImageView blogImageView;
    public Context mContext;

    public ViewHolder(View itemView) {
        mView = itemView;


    public void setDescText(String descText) {

        descView = mView.findViewById(;


    public void setBlogImage(final String downloadUri) {

        blogImageView = mView.findViewById(;


Other method attempted

        mCurrentUser = FirebaseAuth.getInstance().getCurrentUser();
        mImageStorage = FirebaseStorage.getInstance().getReference();

        final String current_uid = mCurrentUser.getUid();

        mUserDatabase = FirebaseDatabase.getInstance().getReference().child("Users").child(current_uid);

        mUserDatabase.addValueEventListener(new ValueEventListener() {
            public void onDataChange(DataSnapshot dataSnapshot) {

                StorageReference filepath = mImageStorage.child("profile_images").child(current_uid + (".jpeg"));
                Log.d("heere", "S");

                // This gets the download url async
                filepath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                    public void onSuccess(Uri uri) {

                        //The download url
                        final String downloadUrl = uri.toString();
                        Log.d("tag", downloadUrl);
                        if (!downloadUrl.equals("default")) {


                        //    Glide.with(getApplicationContext()).load(downloadUrl).into(mDisplayImage);


            public void onCancelled(@NonNull DatabaseError databaseError) {


I would like the image to be displayed in the recycler view


Change this line


to this instead:


All ViewHolder instances have a field itemView that is guaranteed to be non-null, and you can get the context from that.


I have a problem with loading "Glide" image into "ImageView" with "viewPager".

When I try with "drawable" resource it works fine but for some reason (i guess because it is async) it does not wait for Glide to update the view. Nothing crashes just blank viewPager with 3 screens.

P.S Also, the "Firebase" setup is working fine.

I know that is very hard to replicate a problem with this many libs and stuff but if you can throw some suggestions in the comment section it would be great

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

public class ScreenSlidePageFragment extends Fragment {
    public static final String ARG_OBJECT = "object";

    // Firebase Initial code.
    private FirebaseStorage storage = FirebaseStorage.getInstance();
    private StorageReference storageRef = storage.getReferenceFromUrl("gs://myfirebase_example");
    private StorageReference fileRef = storageRef.child("images/3.jpg");

public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(
            R.layout.fragment_screen_slide_page, container, false);

    Bundle args = getArguments();

    //TODO: Find out how to load the images with Glide, now it is not waiting.
    ImageView imageView = (ImageView) rootView.findViewById(;

    // Getting one image from the DB, it is working perfectly.
            .using(new FirebaseImageLoader())

    return rootView;


The problem was missing default image for the ImageView fragment. All is working as expected at the moment.

    app:srcCompat="@android:drawable/screen_background_dark" />