Search in sources :

Example 31 with GlideException

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));
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) List(java.util.List) ArrayList(java.util.ArrayList) GlideException(com.bumptech.glide.load.engine.GlideException) Test(org.junit.Test)

Example 32 with GlideException

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));
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) GlideException(com.bumptech.glide.load.engine.GlideException) Test(org.junit.Test)

Example 33 with GlideException

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));
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) List(java.util.List) ArrayList(java.util.ArrayList) GlideException(com.bumptech.glide.load.engine.GlideException) Test(org.junit.Test)

Example 34 with GlideException

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;
}
Also used : RequestListener(com.bumptech.glide.request.RequestListener) Drawable(android.graphics.drawable.Drawable) TouchImageView(com.dante.custom.TouchImageView) PhotoView(com.github.chrisbanes.photoview.PhotoView) View(android.view.View) DataSource(com.bumptech.glide.load.DataSource) PhotoView(com.github.chrisbanes.photoview.PhotoView) DrawableTransitionOptions(com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions) Target(com.bumptech.glide.request.target.Target) ProgressBar(android.widget.ProgressBar) GlideException(com.bumptech.glide.load.engine.GlideException) Nullable(android.support.annotation.Nullable) NonNull(android.support.annotation.NonNull)

Aggregations

GlideException (com.bumptech.glide.load.engine.GlideException)34 DataSource (com.bumptech.glide.load.DataSource)21 Drawable (android.graphics.drawable.Drawable)18 RequestListener (com.bumptech.glide.request.RequestListener)16 Target (com.bumptech.glide.request.target.Target)16 Nullable (android.support.annotation.Nullable)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Test (org.junit.Test)8 Bitmap (android.graphics.Bitmap)6 Nullable (androidx.annotation.Nullable)6 View (android.view.View)5 ImageView (android.widget.ImageView)5 RequestOptions (com.bumptech.glide.request.RequestOptions)5 Context (android.content.Context)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 GradientDrawable (android.graphics.drawable.GradientDrawable)2 Handler (android.os.Handler)2 CircleGradientDrawable (com.amaze.filemanager.ui.views.CircleGradientDrawable)2