Last active
December 29, 2015 09:09
-
-
Save citizenblr/7648327 to your computer and use it in GitHub Desktop.
Code snippet for "Android & how to use animated GIF" blog post - http://weavora.com/blog/2012/02/07/android-how-to-use-animated-gif/
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
private void setAttrs(AttributeSet attrs) { | |
if (attrs != null) { | |
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.GIFView, 0, 0); | |
String gifSource = a.getString(R.styleable.GIFView_src); | |
//little workaround here. Who knows better approach on how to easily get resource id - please share | |
String sourceName = Uri.parse(gifSource).getLastPathSegment().replace(".gif", ""); | |
setGIFResource(getResources().getIdentifier(sourceName, "drawable", getContext().getPackageName())); | |
a.recycle(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment