Created
April 17, 2015 19:24
-
-
Save koral--/844fae1940dd2c692e7c to your computer and use it in GitHub Desktop.
Getting GifDrawable or default one from resources
This file contains 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
public static Drawable getDrawable(@NonNull Resources resources, @DrawableRes @RawRes int resId, @Nullable Resources.Theme theme) { | |
try { | |
return new GifDrawable(resources, resId); | |
} catch (IOException ignored) { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) | |
return resources.getDrawable(resId, theme); | |
else | |
return resources.getDrawable(resId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment