Skip to content

Instantly share code, notes, and snippets.

@wingoku
Forked from benvd/FadeInNetworkImageView.java
Last active August 29, 2015 14:12
Show Gist options
  • Save wingoku/124f30774798f5983230 to your computer and use it in GitHub Desktop.
Save wingoku/124f30774798f5983230 to your computer and use it in GitHub Desktop.
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.*;
import android.util.AttributeSet;
import com.android.volley.toolbox.NetworkImageView;
public class FadeInNetworkImageView extends NetworkImageView {
private static final int FADE_IN_TIME_MS = 250;
public FadeInNetworkImageView(Context context) {
super(context);
}
public FadeInNetworkImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FadeInNetworkImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void setImageBitmap(Bitmap bm) {
TransitionDrawable td = new TransitionDrawable(new Drawable[]{
new ColorDrawable(android.R.color.transparent),
new BitmapDrawable(getContext().getResources(), bm)
});
setImageDrawable(td);
td.startTransition(FADE_IN_TIME_MS);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment