use of com.bumptech.glide.load.engine.GlideException in project Rocket by mozilla-tw.
the class TabTrayAdapter method loadCachedFavicon.
private void loadCachedFavicon(final Tab tab, final ViewHolder holder) {
RequestOptions options = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.RESOURCE).dontAnimate();
Bitmap favicon = tab.getFavicon();
FaviconModel model = new FaviconModel(tab.getUrl(), FavIconUtils.getFavIconType(holder.itemView.getResources(), favicon), favicon);
requestManager.load(model).apply(options).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
loadGeneratedFavicon(tab, holder);
return true;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
return false;
}
}).into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
updateFavicon(holder, resource);
}
});
}
use of com.bumptech.glide.load.engine.GlideException in project Camera-Roll-Android-App by kollerlukas.
the class AlbumHolder method loadImage.
void loadImage(final ImageView image) {
if (album.getAlbumItems().size() == 0) {
Glide.with(getContext()).load(R.drawable.error_placeholder).apply(new RequestOptions().skipMemoryCache(true)).into(image);
return;
}
final AlbumItem coverImage = album.getAlbumItems().get(0);
Glide.with(getContext()).asBitmap().load(coverImage.getPath()).listener(new RequestListener<Bitmap>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
coverImage.error = true;
if (image instanceof ParallaxImageView) {
((ParallaxImageView) image).setParallaxTranslation();
}
return false;
}
@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
if (!coverImage.hasFadedIn) {
coverImage.hasFadedIn = true;
ColorFade.fadeSaturation(image);
}
if (image instanceof ParallaxImageView) {
((ParallaxImageView) image).setParallaxTranslation();
}
return false;
}
}).apply(coverImage.getGlideRequestOptions(getContext())).into(image);
}
use of com.bumptech.glide.load.engine.GlideException in project Rocket by mozilla-tw.
the class SingleRequest method onResourceReady.
/**
* A callback method that should never be invoked directly.
*/
@SuppressWarnings("unchecked")
@Override
public void onResourceReady(Resource<?> resource, DataSource dataSource) {
stateVerifier.throwIfRecycled();
loadStatus = null;
if (resource == null) {
GlideException exception = new GlideException("Expected to receive a Resource<R> with an " + "object of " + transcodeClass + " inside, but instead got null.");
onLoadFailed(exception);
return;
}
Object received = resource.get();
if (received == null || !transcodeClass.isAssignableFrom(received.getClass())) {
releaseResource(resource);
GlideException exception = new GlideException("Expected to receive an object of " + transcodeClass + " but instead" + " got " + (received != null ? received.getClass() : "") + "{" + received + "} inside" + " " + "Resource{" + resource + "}." + (received != null ? "" : " " + "To indicate failure return a null Resource " + "object, rather than a Resource object containing null data."));
onLoadFailed(exception);
return;
}
if (!canSetResource()) {
releaseResource(resource);
// We can't put the status to complete before asking canSetResource().
status = Status.COMPLETE;
return;
}
onResourceReady((Resource<R>) resource, (R) received, dataSource);
}
use of com.bumptech.glide.load.engine.GlideException in project BaseProject by feer921.
the class GlideImageLoader method addProgressListener.
private void addProgressListener() {
if (getImageUrl() == null)
return;
final String url = getImageUrl();
if (!url.startsWith(HTTP))
return;
internalProgressListener = new OnProgressListener() {
@Override
public void onProgress(String imageUrl, long bytesRead, long totalBytes, boolean isDone, GlideException exception) {
if (totalBytes == 0)
return;
if (!url.equals(imageUrl))
return;
if (mLastBytesRead == bytesRead && mLastStatus == isDone)
return;
mLastBytesRead = bytesRead;
mTotalBytes = totalBytes;
mLastStatus = isDone;
mainThreadCallback(bytesRead, totalBytes, isDone, exception);
if (isDone) {
ProgressManager.removeProgressListener(this);
}
}
};
ProgressManager.addProgressListener(internalProgressListener);
}
use of com.bumptech.glide.load.engine.GlideException in project MaterialViewPager by florent37.
the class MaterialViewPagerImageHelper method setImageUrl.
/**
* change the image with a fade
*
* @param urlImage
* @param fadeDuration TODO : remove Picasso
*/
public static void setImageUrl(final ImageView imageView, final String urlImage, final int fadeDuration) {
final float alpha = ViewCompat.getAlpha(imageView);
final ImageView viewToAnimate = imageView;
// fade to alpha=0
fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationEnd(View view) {
super.onAnimationEnd(view);
// change the image when alpha=0
Glide.with(imageView.getContext()).load(urlImage).apply(new RequestOptions().centerCrop()).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
// then fade to alpha=1
new Handler(Looper.getMainLooper()) {
}.post(new Runnable() {
@Override
public void run() {
fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter());
if (imageLoadListener != null) {
imageLoadListener.OnImageLoad(imageView, ((BitmapDrawable) imageView.getDrawable()).getBitmap());
}
}
});
return false;
}
}).into(viewToAnimate);
}
});
}
Aggregations