Skip to content

Instantly share code, notes, and snippets.

@MFlisar
Created February 7, 2018 06:37
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 MFlisar/5808cba2d6d970552e67d862a715e981 to your computer and use it in GitHub Desktop.
Save MFlisar/5808cba2d6d970552e67d862a715e981 to your computer and use it in GitHub Desktop.
InstantTarget
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.bumptech.glide.request.target.BaseTarget;
import com.bumptech.glide.request.target.SizeReadyCallback;
import com.bumptech.glide.request.transition.Transition;
public class InstantTarget extends BaseTarget<Drawable> {
private Drawable drawable;
private int width;
private int height;
private boolean unlimitedPool;
public InstantTarget(int width, int height) {
this.width = width;
this.height = height;
}
public InstantTarget withUnlimitedPool() {
unlimitedPool = true;
return this;
}
public boolean hasUnlimitedPool() {
return unlimitedPool;
}
public Drawable getDrawable() {
return drawable;
}
public void setDrawable(Drawable d) {
drawable = d;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
@Override
public void onLoadFailed(Drawable errorDrawable) {
// nothing
}
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
// nothing
}
@Override
public final void getSize(SizeReadyCallback cb) {
// nothing
}
@Override
public void removeCallback(@NonNull SizeReadyCallback cb) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment