Skip to content

Instantly share code, notes, and snippets.

@koral--
Created April 17, 2015 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koral--/844fae1940dd2c692e7c to your computer and use it in GitHub Desktop.
Save koral--/844fae1940dd2c692e7c to your computer and use it in GitHub Desktop.
Getting GifDrawable or default one from resources
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