Search in sources :

Example 11 with GlideException

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

Example 12 with GlideException

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

Example 13 with GlideException

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);
    }
}
Also used : RequestListener(com.bumptech.glide.request.RequestListener) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Fragment(android.support.v4.app.Fragment) DataSource(com.bumptech.glide.load.DataSource) Target(com.bumptech.glide.request.target.Target) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) ImageView(android.widget.ImageView) GlideException(com.bumptech.glide.load.engine.GlideException) Nullable(android.support.annotation.Nullable)

Example 14 with GlideException

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);
}
Also used : Target(com.bumptech.glide.request.target.Target) RequestListener(com.bumptech.glide.request.RequestListener) Drawable(android.graphics.drawable.Drawable) CircleGradientDrawable(com.amaze.filemanager.ui.views.CircleGradientDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) GlideException(com.bumptech.glide.load.engine.GlideException) CircleGradientDrawable(com.amaze.filemanager.ui.views.CircleGradientDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) Nullable(android.support.annotation.Nullable) DataSource(com.bumptech.glide.load.DataSource)

Example 15 with GlideException

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);
}
Also used : Target(com.bumptech.glide.request.target.Target) RequestListener(com.bumptech.glide.request.RequestListener) Drawable(android.graphics.drawable.Drawable) CircleGradientDrawable(com.amaze.filemanager.ui.views.CircleGradientDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) ImageView(android.widget.ImageView) View(android.view.View) RoundedImageView(com.amaze.filemanager.ui.views.RoundedImageView) RecyclerView(android.support.v7.widget.RecyclerView) GlideException(com.bumptech.glide.load.engine.GlideException) Nullable(android.support.annotation.Nullable) DataSource(com.bumptech.glide.load.DataSource)

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