use of com.bumptech.glide.load.engine.GlideException in project glide by bumptech.
the class SingleRequestTest method testCallsTargetOnExceptionIfRequestListenerReturnsFalse.
@Test
public void testCallsTargetOnExceptionIfRequestListenerReturnsFalse() {
SingleRequest<List> request = builder.build();
when(builder.requestListener.onLoadFailed(isAGlideException(), any(Number.class), eq(builder.target), anyBoolean())).thenReturn(false);
request.onLoadFailed(new GlideException("test"));
verify(builder.target).onLoadFailed(eq(builder.errorDrawable));
}
use of com.bumptech.glide.load.engine.GlideException in project glide by bumptech.
the class SingleRequestTest method testIsFailedAfterException.
@Test
public void testIsFailedAfterException() {
SingleRequest<List> request = builder.build();
request.onLoadFailed(new GlideException("test"));
assertTrue(request.isFailed());
}
use of com.bumptech.glide.load.engine.GlideException in project android_packages_apps_Dialer by LineageOS.
the class MultimediaFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle bundle) {
super.onViewCreated(view, bundle);
View container = view.findViewById(R.id.answer_message_container);
if (container != null) {
container.setClipToOutline(true);
}
// If the call is spam and only has a subject, update the view to reflect that.
if (isSpam && getLocation() == null && getImageUri() == null && !TextUtils.isEmpty(getSubject())) {
((ImageView) view.findViewById(R.id.spam_image)).setImageResource(R.drawable.quantum_ic_message_white_24);
((TextView) view.findViewById(R.id.spam_text)).setText(R.string.spam_message_text);
}
TextView messageText = view.findViewById(R.id.answer_message_text);
if (messageText != null) {
messageText.setText(getSubject());
}
ImageView mainImage = view.findViewById(R.id.answer_message_image);
if (mainImage != null) {
Glide.with(this).load(getImageUri()).transition(DrawableTransitionOptions.withCrossFade()).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
view.findViewById(R.id.loading_spinner).setVisibility(View.GONE);
LogUtil.e("MultimediaFragment.onLoadFailed", null, e);
// Let Glide handle the rest
return false;
}
@Override
public boolean onResourceReady(Drawable drawable, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
LogUtil.enterBlock("MultimediaFragment.onResourceReady");
view.findViewById(R.id.loading_spinner).setVisibility(View.GONE);
return false;
}
}).into(mainImage);
mainImage.setClipToOutline(true);
}
FrameLayout fragmentHolder = view.findViewById(R.id.answer_message_frag);
if (fragmentHolder != null) {
fragmentHolder.setClipToOutline(true);
Fragment mapFragment = MapsComponent.get(getContext()).getMaps().createStaticMapFragment(getLocation());
getChildFragmentManager().beginTransaction().replace(R.id.answer_message_frag, mapFragment).commitNow();
}
avatarImageView = view.findViewById(R.id.answer_message_avatar);
if (avatarImageView != null) {
avatarImageView.setVisibility(showAvatar ? View.VISIBLE : View.GONE);
}
Holder parent = FragmentUtils.getParent(this, Holder.class);
if (parent != null) {
parent.updateAvatar(this);
}
}
use of com.bumptech.glide.load.engine.GlideException in project AmazeFileManager by TeamAmaze.
the class RecyclerAdapter method showThumbnailWithBackground.
private void showThumbnailWithBackground(ItemViewHolder viewHolder, IconDataParcelable iconData, ImageView view, OnImageProcessed errorListener) {
if (iconData.isImageBroken()) {
viewHolder.genericIcon.setVisibility(View.VISIBLE);
GlideApp.with(mainFrag).load(R.drawable.ic_broken_image_white_24dp).into(viewHolder.genericIcon);
GradientDrawable gradientDrawable = (GradientDrawable) viewHolder.genericIcon.getBackground();
gradientDrawable.setColor(grey_color);
errorListener.onImageProcessed(true);
return;
}
viewHolder.genericIcon.setVisibility(View.VISIBLE);
GlideApp.with(mainFrag).load(iconData.loadingImage).into(viewHolder.genericIcon);
GradientDrawable gradientDrawable = (GradientDrawable) viewHolder.genericIcon.getBackground();
gradientDrawable.setColor(iconSkinColor);
modelProvider.getPreloadRequestBuilder(iconData).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
GlideApp.with(mainFrag).load(R.drawable.ic_broken_image_white_24dp).into(viewHolder.genericIcon);
gradientDrawable.setColor(grey_color);
errorListener.onImageProcessed(true);
return true;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
viewHolder.genericIcon.setImageDrawable(null);
viewHolder.genericIcon.setVisibility(View.GONE);
view.setVisibility(View.VISIBLE);
errorListener.onImageProcessed(false);
return false;
}
}).into(view);
}
use of com.bumptech.glide.load.engine.GlideException in project AmazeFileManager by TeamAmaze.
the class RecyclerAdapter method showRoundedThumbnail.
private void showRoundedThumbnail(ItemViewHolder viewHolder, IconDataParcelable iconData, ImageView view, OnImageProcessed errorListener) {
if (iconData.isImageBroken()) {
View iconBackground = getBoolean(PREFERENCE_USE_CIRCULAR_IMAGES) ? viewHolder.genericIcon : viewHolder.iconLayout;
viewHolder.genericIcon.setVisibility(View.VISIBLE);
iconBackground.setBackgroundColor(grey_color);
GlideApp.with(mainFrag).load(R.drawable.ic_broken_image_white_24dp).into(viewHolder.genericIcon);
view.setVisibility(View.INVISIBLE);
errorListener.onImageProcessed(true);
return;
}
View iconBackground = getBoolean(PREFERENCE_USE_CIRCULAR_IMAGES) ? viewHolder.genericIcon : viewHolder.iconLayout;
iconBackground.setBackgroundColor(iconSkinColor);
viewHolder.genericIcon.setVisibility(View.VISIBLE);
GlideApp.with(mainFrag).load(iconData.loadingImage).into(viewHolder.genericIcon);
view.setVisibility(View.INVISIBLE);
modelProvider.getPreloadRequestBuilder(iconData).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
iconBackground.setBackgroundColor(grey_color);
GlideApp.with(mainFrag).load(R.drawable.ic_broken_image_white_24dp).into(viewHolder.genericIcon);
errorListener.onImageProcessed(true);
return true;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
viewHolder.genericIcon.setImageDrawable(null);
viewHolder.genericIcon.setVisibility(View.GONE);
view.setVisibility(View.VISIBLE);
errorListener.onImageProcessed(false);
return false;
}
}).into(view);
}
Aggregations