Created
February 7, 2018 06:37
-
-
Save MFlisar/5808cba2d6d970552e67d862a715e981 to your computer and use it in GitHub Desktop.
InstantTarget
This file contains hidden or 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
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