Search in sources :

Example 1 with RequestBuilder

use of com.bumptech.glide.RequestBuilder in project BaseProject by feer921.

the class ImageUtil method loadImage.

// public static void loadImage(Context context, String picUrl, int newWidth, int newHeight, Drawable holderDrawable,
// Drawable errorDrawable, ImageView targetIv
// , Callback callback) {
// RequestCreator loadRequest = loadImageRequest(context, picUrl,null,0);
// 
// if (newWidth > 0 && newHeight > 0) {
// loadRequest.resize(newWidth, newHeight);
// loadRequest.centerCrop();
// }
// else{
// //            loadRequest.fit();
// }
// if (holderDrawable != null) {
// loadRequest.placeholder(holderDrawable);
// }
// else{
// loadRequest.noPlaceholder();
// }
// if (errorDrawable != null) {
// loadRequest.error(errorDrawable);
// }
// loadRequest.noFade();
// loadRequest.into(targetIv, callback);
// }
public static void loadImage(Context context, String picUrl, int newWidth, int newHeight, Drawable holderDrawable, Drawable errorDrawable, ImageView targetIv, RequestListener callback) {
    RequestBuilder requestBuilder = loadImageRequest(context, picUrl);
    RequestOptions options = new RequestOptions();
    if (newWidth > 0 && newHeight > 0) {
        options.override(newWidth, newHeight).centerCrop();
    } else {
    // loadRequest.fit();
    }
    if (holderDrawable != null) {
        options.placeholder(holderDrawable);
    } else {
    // loadRequest.noPlaceholder();
    }
    if (errorDrawable != null) {
        options.error(errorDrawable);
    }
    options.dontAnimate();
    if (callback != null) {
        requestBuilder.listener(callback);
    }
    requestBuilder.apply(options).into(targetIv);
}
Also used : RequestBuilder(com.bumptech.glide.RequestBuilder) RequestOptions(com.bumptech.glide.request.RequestOptions)

Example 2 with RequestBuilder

use of com.bumptech.glide.RequestBuilder in project glide by bumptech.

the class GifFrameLoaderTest method setUp.

@SuppressWarnings("unchecked")
@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    when(handler.obtainMessage(anyInt(), isA(DelayTarget.class))).thenReturn(mock(Message.class));
    firstFrame = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
    ByteBuffer byteBuffer = ByteBuffer.allocate(10);
    when(gifDecoder.getData()).thenReturn(byteBuffer);
    requestBuilder = mock(RequestBuilder.class, new ReturnsSelfAnswer());
    loader = createGifFrameLoader(handler);
}
Also used : Message(android.os.Message) RequestBuilder(com.bumptech.glide.RequestBuilder) DelayTarget(com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget) ByteBuffer(java.nio.ByteBuffer) ReturnsSelfAnswer(com.bumptech.glide.tests.Util.ReturnsSelfAnswer) Before(org.junit.Before)

Aggregations

RequestBuilder (com.bumptech.glide.RequestBuilder)2 Message (android.os.Message)1 DelayTarget (com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget)1 RequestOptions (com.bumptech.glide.request.RequestOptions)1 ReturnsSelfAnswer (com.bumptech.glide.tests.Util.ReturnsSelfAnswer)1 ByteBuffer (java.nio.ByteBuffer)1 Before (org.junit.Before)1