Search in sources :

Example 6 with GlideException

use of com.bumptech.glide.load.engine.GlideException in project Camera-Roll-Android-App by kollerlukas.

the class GifViewHolder method loadImage.

@Override
public void loadImage(final ImageView imageView, final AlbumItem albumItem) {
    // super.loadImage(imageView, albumItem);
    RequestOptions options = new RequestOptions().error(R.drawable.error_placeholder).signature(albumItem.getGlideSignature());
    Glide.with(imageView.getContext()).asGif().load(albumItem.getPath()).listener(new RequestListener<GifDrawable>() {

        @Override
        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<GifDrawable> target, boolean isFirstResource) {
            return false;
        }

        @Override
        public boolean onResourceReady(GifDrawable resource, Object model, Target<GifDrawable> target, DataSource dataSource, boolean isFirstResource) {
            if (!albumItem.hasFadedIn) {
                fadeIn();
            } else {
                imageView.clearColorFilter();
            }
            resource.start();
            return false;
        }
    }).apply(options).into(imageView);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) GifDrawable(com.bumptech.glide.load.resource.gif.GifDrawable) GlideException(com.bumptech.glide.load.engine.GlideException) DataSource(com.bumptech.glide.load.DataSource)

Example 7 with GlideException

use of com.bumptech.glide.load.engine.GlideException in project CloudReader by youlookwhat.

the class BaseHeaderActivity method setImgHeaderBg.

/**
 * 加载titlebar背景
 */
private void setImgHeaderBg(String imgUrl) {
    if (!TextUtils.isEmpty(imgUrl)) {
        // 高斯模糊背景 原来 参数:12,5  23,4
        Glide.with(this).load(imgUrl).error(R.drawable.stackblur_default).transform(new BlurTransformation(40, 8)).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) {
                bindingTitleView.tbBaseTitle.setBackgroundColor(Color.TRANSPARENT);
                bindingTitleView.ivBaseTitlebarBg.setImageAlpha(0);
                bindingTitleView.ivBaseTitlebarBg.setVisibility(View.VISIBLE);
                return false;
            }
        }).into(bindingTitleView.ivBaseTitlebarBg);
    }
}
Also used : BlurTransformation(jp.wasabeef.glide.transformations.BlurTransformation) Target(com.bumptech.glide.request.target.Target) RequestListener(com.bumptech.glide.request.RequestListener) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable) GlideException(com.bumptech.glide.load.engine.GlideException) Nullable(androidx.annotation.Nullable) DataSource(com.bumptech.glide.load.DataSource)

Example 8 with GlideException

use of com.bumptech.glide.load.engine.GlideException in project Douya by DreaminginCodeZH.

the class GalleryAdapter method loadImageForPosition.

private void loadImageForPosition(int position, ViewHolder holder) {
    ViewUtils.fadeIn(holder.progress);
    GlideApp.with(holder.progress.getContext()).downloadOnlyDefaultPriority().load(mImageList.get(position)).progressListener(new ProgressListener() {

        @Override
        public void onProgress(long bytesRead, long contentLength, boolean done) {
            int progress = Math.round((float) bytesRead / contentLength * holder.progress.getMax());
            ProgressBarCompat.setProgress(holder.progress, progress, true);
        }
    }).listener(new RequestListener<File>() {

        @Override
        public boolean onResourceReady(File resource, Object model, Target<File> target, DataSource dataSource, boolean isFirstResource) {
            return false;
        }

        @Override
        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<File> target, boolean isFirstResource) {
            showError(e, R.string.gallery_network_error, holder);
            return false;
        }
    }).into(new SimpleTarget<File>() {

        @Override
        public void onResourceReady(File file, Transition<? super File> transition) {
            mFileMap.put(position, file);
            if (mListener != null) {
                mListener.onFileDownloaded(position);
            }
            holder.progress.setIndeterminate(true);
            loadImageFromFile(file, holder);
        }
    });
}
Also used : RequestListener(com.bumptech.glide.request.RequestListener) DataSource(com.bumptech.glide.load.DataSource) SimpleTarget(com.bumptech.glide.request.target.SimpleTarget) Target(com.bumptech.glide.request.target.Target) ProgressListener(me.zhanghai.android.douya.glide.progress.ProgressListener) File(java.io.File) GlideException(com.bumptech.glide.load.engine.GlideException) Nullable(androidx.annotation.Nullable)

Example 9 with GlideException

use of com.bumptech.glide.load.engine.GlideException in project glide by bumptech.

the class SingleRequest method begin.

@Override
public void begin() {
    assertNotCallingCallbacks();
    stateVerifier.throwIfRecycled();
    startTime = LogTime.getLogTime();
    if (model == null) {
        if (Util.isValidDimensions(overrideWidth, overrideHeight)) {
            width = overrideWidth;
            height = overrideHeight;
        }
        // Only log at more verbose log levels if the user has set a fallback drawable, because
        // fallback Drawables indicate the user expects null models occasionally.
        int logLevel = getFallbackDrawable() == null ? Log.WARN : Log.DEBUG;
        onLoadFailed(new GlideException("Received null model"), logLevel);
        return;
    }
    if (status == Status.RUNNING) {
        throw new IllegalArgumentException("Cannot restart a running request");
    }
    // the new load.
    if (status == Status.COMPLETE) {
        onResourceReady(resource, DataSource.MEMORY_CACHE);
        return;
    }
    // Restarts for requests that are neither complete nor running can be treated as new requests
    // and can run again from the beginning.
    status = Status.WAITING_FOR_SIZE;
    if (Util.isValidDimensions(overrideWidth, overrideHeight)) {
        onSizeReady(overrideWidth, overrideHeight);
    } else {
        target.getSize(this);
    }
    if ((status == Status.RUNNING || status == Status.WAITING_FOR_SIZE) && canNotifyStatusChanged()) {
        target.onLoadStarted(getPlaceholderDrawable());
    }
    if (IS_VERBOSE_LOGGABLE) {
        logV("finished run method in " + LogTime.getElapsedMillis(startTime));
    }
}
Also used : GlideException(com.bumptech.glide.load.engine.GlideException)

Example 10 with GlideException

use of com.bumptech.glide.load.engine.GlideException in project glide by bumptech.

the class SingleRequestTest method testIsFailedAfterNoResultAndNullException.

@Test
public void testIsFailedAfterNoResultAndNullException() {
    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)

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