Glide image not loading in React Native native UI Component

Viewed 763

I am creating a React Native native UI Component. It is an image gallery that requires loading images from URL. In my PageAdapter, I am loading the image using the following code but the image is not loading.

    Glide.with(context).load(url).listener(new RequestListener<Drawable>() {
        @Override
        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
            Log.e("ImageLoader", "Load failed", e);
            return false;
        }

        @Override
        public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
            Log.i("ImageLoader", "Successfully loaded");
            return false;
        }
    }).override(720, 1280).into(imageView);

The onResourceReady method is always hitting but no image is loading. How do I solve this?

1 Answers

Try using:

Glide.with(context)
        .asBitmap()
        .load(url)
        .into(new CustomTarget<Bitmap>(720,1280) {
            @Override
            public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                imageView.setImageBitmap(resource);
            }

            @Override
            public void onLoadCleared(@Nullable Drawable placeholder) {
            }
        });  

and make sure you are using the latest version

implementation 'com.github.bumptech.glide:glide:4.9.0'
Related