therealshabi/AutoImageFlipper

Not showing correct image

Closed this issue · 1 comments

I am using the .setImageUrl() method to set image to the layout.
But the image link that I am passing and the image that it shows on the phone are different images.

Here is the code
FlipperView view = new FlipperView(this.getActivity());
view.setImageUrl(res.getJSONObject(i)
.getString("img_link"));
view.setImageScaleType(ImageView.ScaleType.FIT_CENTER);
view.setDescription("");
view.setDescriptionBackground(Color.TRANSPARENT,1);

The image link is --> https://cdn11.bigcommerce.com/s-7uw7zc08qw/images/stencil/1296w/carousel/28/KakaoTalk_20200114_190440262.jpg?c=2

And this what I am getting -->
Screenshot_20200528-213620

Why is this coming? How to solve this?

Hey @aana77 Sorry for the late reply, but the method that you're using actually just sets the image URL for the flipper view, you have to handle the loading part of it, using any method that you want, be it okhttp, Picasso, Glide etc. The image that is visible to you is just the placeholder image, which shouldn't have been visible here ideally.

The method that you should use is:

try {
                view.setImage(res.getJSONObject(i), new Function2<ImageView, Object, Unit>() {
                    @Override
                    public Unit invoke(ImageView imageView, Object image) {
                        // Any method that you would use to load that image
                        // E.g. Picasso.get().load((String) image).into(imageView);
                        return Unit.INSTANCE;
                    }
                });
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }

Also, you'll need to have a Kotlin dependency in your project for this to work unfortunately