use of com.bumptech.glide.load.engine.GlideException in project glide by bumptech.
the class SingleRequestTest method testDoesNotSetErrorDrawableIfRequestCoordinatorDoesntAllowIt.
@Test
public void testDoesNotSetErrorDrawableIfRequestCoordinatorDoesntAllowIt() {
SingleRequest<List> request = builder.setErrorDrawable(new ColorDrawable(Color.RED)).build();
when(builder.requestCoordinator.canNotifyStatusChanged(any(Request.class))).thenReturn(false);
request.onLoadFailed(new GlideException("test"));
verify(builder.target, never()).onLoadFailed(any(Drawable.class));
}
use of com.bumptech.glide.load.engine.GlideException in project glide by bumptech.
the class SingleRequestTest method testCallsTargetOnExceptionIfNoRequestListener.
@Test
public void testCallsTargetOnExceptionIfNoRequestListener() {
SingleRequest<List> request = builder.setRequestListener(null).build();
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 testDoesNotCallTargetOnExceptionIfRequestListenerReturnsTrue.
@Test
public void testDoesNotCallTargetOnExceptionIfRequestListenerReturnsTrue() {
SingleRequest<List> request = builder.build();
when(builder.requestListener.onLoadFailed(isAGlideException(), any(Number.class), eq(builder.target), anyBoolean())).thenReturn(true);
request.onLoadFailed(new GlideException("test"));
verify(builder.target, never()).onLoadFailed(any(Drawable.class));
}
use of com.bumptech.glide.load.engine.GlideException in project 91Pop by DanteAndroid.
the class PictureAdapter method instantiateItem.
@NonNull
@Override
public View instantiateItem(@NonNull ViewGroup container, final int position) {
View contentView = LayoutInflater.from(container.getContext()).inflate(R.layout.item_picture_adapter, container, false);
PhotoView photoView = contentView.findViewById(R.id.photoView);
final ProgressBar progressBar = contentView.findViewById(R.id.progressBar);
String url = imageList.get(position);
if (url.contains("meizitu.net")) {
GlideApp.with(container).load(buildGlideUrl(url)).transition(new DrawableTransitionOptions().crossFade(300)).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
}).into(photoView);
} else {
GlideApp.with(container).load(Uri.parse(url)).transition(new DrawableTransitionOptions().crossFade(300)).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
}).into(photoView);
}
// Now just add PhotoView to ViewPager and return it
container.addView(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
photoView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onImageClickListener != null) {
onImageClickListener.onImageClick(v, position);
}
}
});
photoView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (onImageClickListener != null) {
onImageClickListener.onImageLongClick(v, position);
}
return true;
}
});
Logger.t(TAG).d("instantiateItem");
return contentView;
}
Aggregations