com.bumptech.glide.request.RequestListener Java Examples

The following examples show how to use com.bumptech.glide.request.RequestListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: DoraemonKit   Author: didi   File: GlideHook.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * hook requestListeners字段
 *
 * @param singleRequest
 * @return
 */

public static void proxy(Object singleRequest) {
    try {
        List<RequestListener> requestListeners = null;
        if (singleRequest instanceof SingleRequest) {
            requestListeners = ReflectUtils.reflect(singleRequest).field("requestListeners").get();
        }
        //可能存在用户没有引入okhttp的情况
        if (requestListeners == null) {
            requestListeners = new ArrayList<>();
            requestListeners.add(new DokitGlideRequestListener());
        } else {
            requestListeners.add(new DokitGlideRequestListener());
        }
        if (singleRequest instanceof SingleRequest) {
            ReflectUtils.reflect(singleRequest).field("requestListeners",requestListeners);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #2
Source Project: social-app-android   Author: rozdoum   File: ImageUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void loadMediumImageCenterCrop(GlideRequests glideRequests,
                                             StorageReference imageStorageRefMedium,
                                             StorageReference imageStorageRefOriginal,
                                             ImageView imageView,
                                             int width,
                                             int height,
                                             RequestListener<Drawable> listener) {

    glideRequests.load(imageStorageRefMedium)
            .centerCrop()
            .override(width, height)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .error(R.drawable.ic_stub)
            .listener(listener)
            .error(glideRequests.load(imageStorageRefOriginal))
            .into(imageView);
}
 
Example #3
Source Project: aptoide-client-v8   Author: Aptoide   File: ImageLoader.java    License: GNU General Public License v3.0 6 votes vote down vote up
public Target<Drawable> loadWithColorPlaceholderRoundCorners(String image, int radius,
    ImageView previewImage, @AttrRes int colorResource,
    RequestListener<Drawable> requestListener) {
  Context context = weakContext.get();
  if (context != null) {
    return Glide.with(context)
        .load(image)
        .apply(getRequestOptions().centerCrop()
            .placeholder(new ColorDrawable(getAttrColor(colorResource)))
            .transforms(new CenterCrop(), new RoundedCorners(radius)))
        .listener(requestListener)
        .transition(DrawableTransitionOptions.withCrossFade())
        .into(previewImage);
  }
  return null;
}
 
Example #4
Source Project: SendBird-Android   Author: sendbird   File: ImageUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Displays an image from a URL in an ImageView.
 */
public static void displayImageFromUrl(final Context context, final String url,
                                       final ImageView imageView, Drawable placeholderDrawable, RequestListener listener) {
    RequestOptions myOptions = new RequestOptions()
            .dontAnimate()
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .placeholder(placeholderDrawable);

    if (listener != null) {
        Glide.with(context)
                .load(url)
                .apply(myOptions)
                .listener(listener)
                .into(imageView);
    } else {
        Glide.with(context)
                .load(url)
                .apply(myOptions)
                .listener(listener)
                .into(imageView);
    }
}
 
Example #5
Source Project: SendBird-Android   Author: sendbird   File: ImageUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Displays an image from a URL in an ImageView.
 */
public static void displayGifImageFromUrl(Context context, String url, ImageView imageView, Drawable placeholderDrawable, RequestListener listener) {
    RequestOptions myOptions = new RequestOptions()
            .dontAnimate()
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .placeholder(placeholderDrawable);

    if (listener != null) {
        Glide.with(context)
                .asGif()
                .load(url)
                .apply(myOptions)
                .listener(listener)
                .into(imageView);
    } else {
        Glide.with(context)
                .asGif()
                .load(url)
                .apply(myOptions)
                .into(imageView);
    }
}
 
Example #6
Source Project: SendBird-Android   Author: sendbird   File: ImageUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Displays an image from a URL in an ImageView.
 */
public static void displayImageFromUrl(final Context context, final String url,
                                       final ImageView imageView, RequestListener listener) {
    RequestOptions myOptions = new RequestOptions()
            .dontAnimate()
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC);

    if (listener != null) {
        Glide.with(context)
                .load(url)
                .apply(myOptions)
                .listener(listener)
                .into(imageView);
    } else {
        Glide.with(context)
                .load(url)
                .apply(myOptions)
                .listener(listener)
                .into(imageView);
    }
}
 
Example #7
Source Project: SendBird-Android   Author: sendbird   File: ImageUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Displays an image from a URL in an ImageView.
 */
public static void displayGifImageFromUrl(Context context, String url, ImageView imageView, RequestListener listener) {
    RequestOptions myOptions = new RequestOptions()
            .dontAnimate()
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC);

    if (listener != null) {
        Glide.with(context)
                .asGif()
                .load(url)
                .apply(myOptions)
                .listener(listener)
                .into(imageView);
    } else {
        Glide.with(context)
                .asGif()
                .load(url)
                .apply(myOptions)
                .into(imageView);
    }
}
 
Example #8
Source Project: BaseProject   Author: feer921   File: ImageUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void loadImage(Context context, String picUrl, int newWidth, int newHeight, int holderDrawableResId,
                             int errorDrawableResId, ImageView targetIv
        , RequestListener callback){
    Resources res = context.getResources();
    Drawable holderPic = null;
    if (holderDrawableResId > 0) {
        holderPic = res.getDrawable(holderDrawableResId);
    }
    Drawable errorDrawable = null;
    if (errorDrawableResId > 0) {
        errorDrawable = res.getDrawable(errorDrawableResId);
    }
    loadImage(context, picUrl, newWidth, newHeight,holderPic,
            errorDrawable,
            targetIv, callback);
}
 
Example #9
Source Project: giffun   Author: guolindev   File: DrawableRequestBuilder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public DrawableRequestBuilder<ModelType> listener(
        RequestListener<? super ModelType, GlideDrawable> requestListener) {
    super.listener(requestListener);
    return this;
}
 
Example #10
Source Project: giffun   Author: guolindev   File: GifRequestBuilder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public GifRequestBuilder<ModelType> listener(
        RequestListener<? super ModelType, GifDrawable> requestListener) {
    super.listener(requestListener);
    return this;
}
 
Example #11
Source Project: giffun   Author: guolindev   File: BitmapRequestBuilder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public BitmapRequestBuilder<ModelType, TranscodeType> listener(
        RequestListener<? super ModelType, TranscodeType> requestListener) {
    super.listener(requestListener);
    return this;
}
 
Example #12
Source Project: DevUtils   Author: afkT   File: GlideUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 图片显示
 * <pre>
 *     支持显示 Gif 图片第一帧
 * </pre>
 * @param uri       Image Uri
 * @param imageView ImageView
 * @param options   {@link RequestOptions}
 * @param listener  加载监听事件
 */
public void displayImage(final String uri, final ImageView imageView, final RequestOptions options,
                         final RequestListener<Bitmap> listener) {
    if (mRequestManager != null && imageView != null) {
        if (options != null) {
            mRequestManager.asBitmap().load(uri).apply(options).listener(listener).into(imageView);
        } else {
            mRequestManager.asBitmap().load(uri).listener(listener).into(imageView);
        }
    }
}
 
Example #13
Source Project: DevUtils   Author: afkT   File: GlideUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 图片显示
 * @param uri       Image Uri
 * @param imageView ImageView
 * @param options   {@link RequestOptions}
 * @param listener  加载监听事件
 */
public void displayImageToGif(final String uri, final ImageView imageView, final RequestOptions options,
                              final RequestListener<GifDrawable> listener) {
    if (mRequestManager != null && imageView != null) {
        if (options != null) {
            mRequestManager.asGif().load(uri).apply(options).listener(listener).into(imageView);
        } else {
            mRequestManager.asGif().load(uri).listener(listener).into(imageView);
        }
    }
}
 
Example #14
Source Project: DevUtils   Author: afkT   File: GlideUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 图片显示
 * @param uri       Image Uri
 * @param imageView ImageView
 * @param options   {@link RequestOptions}
 * @param listener  加载监听事件
 */
public void displayImageToDrawable(final String uri, final ImageView imageView, final RequestOptions options,
                                   final RequestListener<Drawable> listener) {
    if (mRequestManager != null && imageView != null) {
        if (options != null) {
            mRequestManager.asDrawable().load(uri).apply(options).listener(listener).into(imageView);
        } else {
            mRequestManager.asDrawable().load(uri).listener(listener).into(imageView);
        }
    }
}
 
Example #15
Source Project: DevUtils   Author: afkT   File: GlideUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 图片显示
 * @param uri       Image Uri
 * @param imageView ImageView
 * @param options   {@link RequestOptions}
 * @param listener  加载监听事件
 */
public void displayImageToFile(final String uri, final ImageView imageView, final RequestOptions options,
                               final RequestListener<File> listener) {
    if (mRequestManager != null && imageView != null) {
        if (options != null) {
            mRequestManager.asFile().load(uri).apply(options).listener(listener).into(imageView);
        } else {
            mRequestManager.asFile().load(uri).listener(listener).into(imageView);
        }
    }
}
 
Example #16
Source Project: social-app-android   Author: emonm   File: ImageUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadImage(GlideRequests glideRequests, String url, ImageView imageView,
                             RequestListener<Drawable> listener) {
    glideRequests.load(url)
            .error(R.drawable.ic_stub)
            .listener(listener)
            .diskCacheStrategy(DiskCacheStrategy.DATA)
            .into(imageView);
}
 
Example #17
Source Project: social-app-android   Author: emonm   File: ImageUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadImageCenterCrop(GlideRequests glideRequests, String url, ImageView imageView,
                                       int width, int height, RequestListener<Drawable> listener) {
    glideRequests.load(url)
            .centerCrop()
            .override(width, height)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .error(R.drawable.ic_stub)
            .listener(listener)
            .into(imageView);
}
 
Example #18
Source Project: social-app-android   Author: emonm   File: ImageUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadImageCenterCrop(GlideRequests glideRequests, String url, ImageView imageView,
                                       RequestListener<Drawable> listener) {
    glideRequests.load(url)
            .centerCrop()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .error(R.drawable.ic_stub)
            .listener(listener)
            .into(imageView);
}
 
Example #19
Source Project: social-app-android   Author: emonm   File: ImageUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadLocalImage(GlideRequests glideRequests, Uri uri, ImageView imageView,
                                  RequestListener<Drawable> listener) {
    glideRequests.load(uri)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .skipMemoryCache(true)
            .fitCenter()
            .listener(listener)
            .into(imageView);
}
 
Example #20
Source Project: social-app-android   Author: rozdoum   File: ImageUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadImage(GlideRequests glideRequests, String url, ImageView imageView,
                             RequestListener<Drawable> listener) {
    glideRequests.load(url)
            .error(R.drawable.ic_stub)
            .listener(listener)
            .diskCacheStrategy(DiskCacheStrategy.DATA)
            .into(imageView);
}
 
Example #21
Source Project: social-app-android   Author: rozdoum   File: ImageUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadImageCenterCrop(GlideRequests glideRequests, StorageReference imageStorageRef, ImageView imageView,
                                       int width, int height, RequestListener<Drawable> listener) {
    glideRequests.load(imageStorageRef)
            .centerCrop()
            .override(width, height)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .error(R.drawable.ic_stub)
            .listener(listener)
            .into(imageView);
}
 
Example #22
Source Project: social-app-android   Author: rozdoum   File: ImageUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadImageCenterCrop(GlideRequests glideRequests, String url, ImageView imageView,
                                       int width, int height, RequestListener<Drawable> listener) {
    glideRequests.load(url)
            .centerCrop()
            .override(width, height)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .error(R.drawable.ic_stub)
            .listener(listener)
            .into(imageView);
}
 
Example #23
Source Project: social-app-android   Author: rozdoum   File: ImageUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadImageCenterCrop(GlideRequests glideRequests, StorageReference imageStorageRef, ImageView imageView,
                                       RequestListener<Drawable> listener) {
    glideRequests.load(imageStorageRef)
            .centerCrop()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .error(R.drawable.ic_stub)
            .listener(listener)
            .into(imageView);
}
 
Example #24
Source Project: social-app-android   Author: rozdoum   File: ImageUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadImageCenterCrop(GlideRequests glideRequests, String url, ImageView imageView,
                                       RequestListener<Drawable> listener) {
    glideRequests.load(url)
            .centerCrop()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .error(R.drawable.ic_stub)
            .listener(listener)
            .into(imageView);
}
 
Example #25
Source Project: social-app-android   Author: rozdoum   File: ImageUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadLocalImage(GlideRequests glideRequests, Uri uri, ImageView imageView,
                                  RequestListener<Drawable> listener) {
    glideRequests.load(uri)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .skipMemoryCache(true)
            .fitCenter()
            .listener(listener)
            .into(imageView);
}
 
Example #26
Source Project: aptoide-client-v8   Author: Aptoide   File: ImageLoader.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Target<Drawable> loadWithRoundCorners(String image, int radius, ImageView previewImage,
    @AttrRes int placeHolderDrawableId, RequestListener<Drawable> requestListener) {
  Context context = weakContext.get();
  if (context != null) {
    return Glide.with(context)
        .load(image)
        .apply(getRequestOptions().centerCrop()
            .placeholder(getAttrDrawable(placeHolderDrawableId))
            .transforms(new CenterCrop(), new RoundedCorners(radius)))
        .listener(requestListener)
        .transition(DrawableTransitionOptions.withCrossFade())
        .into(previewImage);
  }
  return null;
}
 
Example #27
Source Project: glide-support   Author: TWiStErRob   File: MultiRequestListener.java    License: The Unlicense 5 votes vote down vote up
@Override public boolean onException(Exception e, A model, Target<B> target, boolean isFirstResource) {
	for (RequestListener<? super A, B> listener : listeners) {
		if (listener.onException(e, model, target, isFirstResource)) {
			return true;
		}
	}
	return false;
}
 
Example #28
Source Project: glide-support   Author: TWiStErRob   File: MultiRequestListener.java    License: The Unlicense 5 votes vote down vote up
@Override public boolean onResourceReady(B resource, A model, Target<B> target, boolean isFromMemoryCache,
		boolean isFirstResource) {
	for (RequestListener<? super A, B> listener : listeners) {
		if (listener.onResourceReady(resource, model, target, isFromMemoryCache, isFirstResource)) {
			return true;
		}
	}
	return false;
}
 
Example #29
Source Project: RetailStore   Author: ashishbhandari   File: ImageLoader.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Load an image from a url into an ImageView using the default placeholder
 * drawable if available.
 * @param url The web URL of an image.
 * @param imageView The target ImageView to load the image into.
 * @param requestListener A listener to monitor the request result.
 * @param placeholderOverride A drawable to use as a placeholder for this specific image.
 *                            If this parameter is present, {@link #mPlaceHolderResId}
 *                            if ignored for this request.
 */
public void loadImage(String url, ImageView imageView, RequestListener<String, Bitmap> requestListener,
            Drawable placeholderOverride, boolean crop) {
    BitmapRequestBuilder request = beginImageLoad(url, requestListener, crop)
            .animate(R.anim.image_fade_in);
    if (placeholderOverride != null) {
        request.placeholder(placeholderOverride);
    } else if (mPlaceHolderResId != -1) {
        request.placeholder(mPlaceHolderResId);
    }
    request.into(imageView);
}
 
Example #30
Source Project: RetailStore   Author: ashishbhandari   File: ImageLoader.java    License: Apache License 2.0 5 votes vote down vote up
public BitmapRequestBuilder beginImageLoad(String url,
        RequestListener<String, Bitmap> requestListener, boolean crop) {
    if (crop){
        return mGlideModelRequest.load(url)
                .listener(requestListener)
                .transform(mCenterCrop);
    } else {
        return mGlideModelRequest.load(url)
                .listener(requestListener);
    }
}