Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dzwillpower/8193499 to your computer and use it in GitHub Desktop.
Save dzwillpower/8193499 to your computer and use it in GitHub Desktop.
异步加载图片 动画渐变出来
public class AlphaImageFetchTask extends BaseImageFetchTask {
public AlphaImageFetchTask(String url, int targetWidth, int targetHeight) {
super(url, targetWidth, targetHeight);
}
public AlphaImageFetchTask(String url, int targetWidth, int targetHeight, String key) {
super(url, targetWidth, targetHeight, key);
}
@Override
public void setDrawable(View view, Drawable drawable) {
if(drawable instanceof AsyncDrawable){
super.setDrawable(view, drawable);
}else{
Drawable[] drawables=new Drawable[2];
drawables[0]=new ColorDrawable(0);
drawables[1]=drawable;
TransitionDrawable td=new TransitionDrawable(drawables);
td.startTransition(300);
super.setDrawable(view, td);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment