0

ImageSwitcher slide animation not work when use glide to load.

imageSwitcher.setInAnimation(In);
imageSwitcher.setOutAnimation(Out);
Glide
     .with(getActivity())
     .load(imageURL)
     .into((ImageView) imageSwitcher.getCurrentView());

This animation works fine when load image form local resource without glide

imageSwitcher.setImageResource(data.get(position).getImage_drawable());
Zoe
  • 27,060
  • 21
  • 118
  • 148
Wahab Khan Jadon
  • 875
  • 13
  • 21

1 Answers1

0

Just use it like this:

Glide.with(view.context)
            .asDrawable()
            .load(url)
            .listener(object : RequestListener<Drawable> {
                override fun onLoadFailed(
                    e: GlideException?,
                    model: Any?,
                    target: Target<Drawable>?,
                    isFirstResource: Boolean
                ) = false

                override fun onResourceReady(
                    resource: Drawable?,
                    model: Any?,
                    target: Target<Drawable>?,
                    dataSource: DataSource?,
                    isFirstResource: Boolean
                ): Boolean {
                    (view.nextView as? ImageView)?.setImageDrawable(resource)
                    view.showNext()
                    return true
                }
            })
            .submit()
Artyom A.
  • 1
  • 2
  • From Review: Hi, please don't answer just with source code. Try to provide a nice description about how your solution works. See: [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer). Thanks – sɐunıɔןɐqɐp Jan 21 '19 at 09:37