Last active
May 27, 2020 06:47
-
-
Save samuel22gj/1934d8ef796a20f242eb82ab58f920bb to your computer and use it in GitHub Desktop.
Glide v4 target for GifDrawable or Drawable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A target for display {@link GifDrawable} or {@link Drawable} objects in {@link ImageView}s. | |
*/ | |
public class GifDrawableImageViewTarget extends ImageViewTarget<Drawable> { | |
private int mLoopCount = GifDrawable.LOOP_FOREVER; | |
public GifDrawableImageViewTarget(ImageView view, int loopCount) { | |
super(view); | |
mLoopCount = loopCount; | |
} | |
public GifDrawableImageViewTarget(ImageView view, int loopCount, boolean waitForLayout) { | |
super(view, waitForLayout); | |
mLoopCount = loopCount; | |
} | |
@Override | |
protected void setResource(@Nullable Drawable resource) { | |
if (resource instanceof GifDrawable) { | |
((GifDrawable) resource).setLoopCount(mLoopCount); | |
} | |
view.setImageDrawable(resource); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment