简体   繁体   中英

Glide not loading images

I've already asked this question but I didn't really get an answer yet but I figured I didn't provide enough details or code so I decided to delete the question. So I have images saved in the database(Firebase) and I'm trying to display them in a Recyclerview and I notice that Glide is not loading the image. I see the cardView being displayed with a black screen and no image. I'm seeing that I get these warning messages about glide loading failed etc. I don't know what seems to be the problem because Glide is working fine on my other project. I will provide my full code and also the warning messages that I am receiving. Hopefully, someone can help me with his issue. Thanks in advance

Warning messages:

    > W/Glide: Load failed for null with size [0x0]
        class com.bumptech.glide.load.engine.GlideException: Received null model
    W/Glide: Load failed for null with size [0x0]
        class com.bumptech.glide.load.engine.GlideException: Received null model
    V/FA: Inactivity, disconnecting from the service
    W/ConnectionTracker: Exception thrown while unbinding
        java.lang.IllegalArgumentException: Service not registered: com.google.android.gms.measurement.internal.zzjp@68d387d
            at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1494)

Model class:

    public class Model_Information {
    
        public String mImageUrl;
    
        public Model_Information(S String  mImageUrl) {
    
            this.mImageUrl =  mImageUrl;
         
        }
    
        public Model_Information() {
    
        }
    
        public String getmImageUrl() {
            return mImageUrl;
        }
    
        public void setmImageUrl(String mImageUrl) {
            this.mImageUrl = mImageUrl;
        }
    }

Adapter class:

    public class Adapter extends  RecyclerView.Adapter<Adapter.ImageViewHolder>{
    
        private Context mContext;
        private ArrayList<Model_Information> users;
    
        public Adapter(Context context, ArrayList<Model_Information> uploads){
            mContext = context;
            users = uploads;
    
        }
    
        @NonNull
        @Override
        public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View V = LayoutInflater.from(mContext).inflate(R.layout.cardview1, parent, false);
            return new ImageViewHolder(V);
        }
    
        @Override
        public void onBindViewHolder(@NonNull final ImageViewHolder holder, final int position) {
            Glide.with(mContext).load(users.get(position).getmImageUrl()).thumbnail(0.05f).transition(DrawableTransitionOptions.withCrossFade()).fitCenter().centerInside().into(holder.imageView);
            holder.imageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
    
                    Intent intent=new Intent(mContext,ViewActivity.class);
                    intent.putExtra("image",users.get(position).getmImageUrl());
               
                    mContext.startActivity(intent);
                }
            });
        }
    
        @Override
        public int getItemCount() {
            return users.size();
    
        }
    
        public class ImageViewHolder extends RecyclerView.ViewHolder{
            public ImageView imageView;
    
            public ImageViewHolder(@NonNull View itemView) {
                super(itemView);
    
                imageView=itemView.findViewById(R.id.imageview);
            }
        }
    

Main class:

     databaseReference = FirebaseDatabase.getInstance("https://poot0-44881.firebaseio.com").getReference("Images");
    
            firebaseStorage = FirebaseStorage.getInstance();
            storageReference = firebaseStorage.getReference();
    
            firebaseUser = firebaseAuth.getInstance().getCurrentUser();    
            
            databaseReference.addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
    
                    progressBar.setVisibility(View.GONE);
    
                    if(dataSnapshot.exists()){
    
                        for (DataSnapshot postsnapshot : dataSnapshot.getChildren()) {
    
                            Model_Information upload=postsnapshot.getValue(Model_Information.class);
    
                            myUploads.add(upload);
                            aAdapter = new Adapter(MainActivity2.this, myUploads);
                            recyclerView.setAdapter(aAdapter);
                            aAdapter.notifyDataSetChanged();
                            recyclerView.invalidate();
    
    
                        }
                        aAdapter.notifyDataSetChanged();
    
                    }else{
    
                    }

So I have found my issue. Instead of using addValueEventListener I must use addChildEventListener since I am trying to get Data from another firebase project or database. Hopefully someone find this answer useful

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM