Java 类com.bumptech.glide.load.engine.GlideException 实例源码

项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testCallsTargetOnExceptionIfNoRequestListener() {
  harness.requestListener = null;
  SingleRequest<List> request = harness.getRequest();
  request.onLoadFailed(new GlideException("test"));

  verify(harness.target).onLoadFailed(eq(harness.errorDrawable));
}
项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testCallsTargetOnExceptionIfRequestListenerReturnsFalse() {
  SingleRequest<List> request = harness.getRequest();
  when(harness.requestListener.onLoadFailed(isAGlideException(), any(Number.class),
      eq(harness.target), anyBoolean()))
      .thenReturn(false);
  request.onLoadFailed(new GlideException("test"));

  verify(harness.target).onLoadFailed(eq(harness.errorDrawable));
}
项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testDoesNotCallTargetOnExceptionIfRequestListenerReturnsTrue() {
  SingleRequest<List> request = harness.getRequest();
  when(harness.requestListener.onLoadFailed(isAGlideException(), any(Number.class),
      eq(harness.target), anyBoolean()))
      .thenReturn(true);

  request.onLoadFailed(new GlideException("test"));

  verify(harness.target, never()).onLoadFailed(any(Drawable.class));
}
项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testDoesNotSetErrorDrawableIfRequestCoordinatorDoesntAllowIt() {
  harness.errorDrawable = new ColorDrawable(Color.RED);
  SingleRequest<List> request = harness.getRequest();
  when(harness.requestCoordinator.canNotifyStatusChanged(any(Request.class))).thenReturn(false);
  request.onLoadFailed(new GlideException("test"));

  verify(harness.target, never()).onLoadFailed(any(Drawable.class));
}
项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testErrorDrawableIsSetOnLoadFailed() {
  Drawable expected = new ColorDrawable(Color.RED);

  MockTarget target = new MockTarget();

  harness.errorDrawable = expected;
  harness.target = target;
  SingleRequest<List> request = harness.getRequest();

  request.onLoadFailed(new GlideException("test"));

  assertEquals(expected, target.currentPlaceholder);
}
项目:GitHub    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onLoadFailed(GlideException e, Object model, Target<PictureDrawable> target,
    boolean isFirstResource) {
  ImageView view = ((ImageViewTarget<?>) target).getView();
  view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
  return false;
}
项目:GitHub    文件:SingleRequest.java   
private void onLoadFailed(GlideException e, int maxLogLevel) {
  stateVerifier.throwIfRecycled();
  int logLevel = glideContext.getLogLevel();
  if (logLevel <= maxLogLevel) {
    Log.w(GLIDE_TAG, "Load failed for " + model + " with size [" + width + "x" + height + "]", e);
    if (logLevel <= Log.INFO) {
      e.logRootCauses(GLIDE_TAG);
    }
  }

  loadStatus = null;
  status = Status.FAILED;
  //TODO: what if this is a thumbnail request?
  if (requestListener == null
      || !requestListener.onLoadFailed(e, model, target, isFirstReadyResource())) {
    setErrorPlaceholder();
  }
}
项目:GitHub    文件:SvgSoftwareLayerSetter.java   
@Override
public boolean onLoadFailed(GlideException e, Object model, Target<PictureDrawable> target,
    boolean isFirstResource) {
  ImageView view = ((ImageViewTarget<?>) target).getView();
  view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
  return false;
}
项目:BaseProject    文件:GlideImageLoader.java   
private void addProgressListener() {
    if (getImageUrl() == null) return;
    final String url = getImageUrl();
    if (!url.startsWith(HTTP)) return;

    internalProgressListener = new OnProgressListener() {
        @Override
        public void onProgress(String imageUrl, long bytesRead, long totalBytes, boolean isDone, GlideException exception) {
            if (totalBytes == 0) return;
            if (!url.equals(imageUrl)) return;
            if (mLastBytesRead == bytesRead && mLastStatus == isDone) return;

            mLastBytesRead = bytesRead;
            mTotalBytes = totalBytes;
            mLastStatus = isDone;
            mainThreadCallback(bytesRead, totalBytes, isDone, exception);

            if (isDone) {
                ProgressManager.removeProgressListener(this);
            }
        }
    };
    ProgressManager.addProgressListener(internalProgressListener);
}
项目:GitHub    文件:SingleRequest.java   
@Override
public void begin() {
  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;
  }

  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 (Log.isLoggable(TAG, Log.VERBOSE)) {
    logV("finished run method in " + LogTime.getElapsedMillis(startTime));
  }
}
项目:GitHub    文件:MultiModelLoader.java   
private void startNextOrFail() {
  if (currentIndex < fetchers.size() - 1) {
    currentIndex++;
    loadData(priority, callback);
  } else {
    callback.onLoadFailed(new GlideException("Fetch failed", new ArrayList<>(exceptions)));
  }
}
项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testIsFailedAfterException() {
  SingleRequest<List> request = harness.getRequest();

  request.onLoadFailed(new GlideException("test"));
  assertTrue(request.isFailed());
}
项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testIsFailedAfterNoResultAndNullException() {
  SingleRequest<List> request = harness.getRequest();

  request.onLoadFailed(new GlideException("test"));
  assertTrue(request.isFailed());
}
项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testIsNotRunningAfterFailing() {
  SingleRequest<List> request = harness.getRequest();
  request.begin();
  request.onLoadFailed(new GlideException("test"));

  assertFalse(request.isRunning());
}
项目:GitHub    文件:RequestFutureTarget.java   
@Override
public synchronized boolean onLoadFailed(
    @Nullable GlideException e, Object model, Target<R> target, boolean isFirstResource) {
  loadFailed = true;
  exception = e;
  waiter.notifyAll(this);
  return false;
}
项目:GitHub    文件:SingleRequest.java   
private void onLoadFailed(GlideException e, int maxLogLevel) {
  stateVerifier.throwIfRecycled();
  int logLevel = glideContext.getLogLevel();
  if (logLevel <= maxLogLevel) {
    Log.w(GLIDE_TAG, "Load failed for " + model + " with size [" + width + "x" + height + "]", e);
    if (logLevel <= Log.INFO) {
      e.logRootCauses(GLIDE_TAG);
    }
  }

  loadStatus = null;
  status = Status.FAILED;

  isCallingCallbacks = true;
  try {
    //TODO: what if this is a thumbnail request?
    if ((requestListener == null
        || !requestListener.onLoadFailed(e, model, target, isFirstReadyResource()))
        && (targetListener == null
        || !targetListener.onLoadFailed(e, model, target, isFirstReadyResource()))) {
      setErrorPlaceholder();
    }
  } finally {
    isCallingCallbacks = false;
  }

  notifyLoadFailed();
}
项目:GitHub    文件:MultiModelLoader.java   
private void startNextOrFail() {
  if (currentIndex < fetchers.size() - 1) {
    currentIndex++;
    loadData(priority, callback);
  } else {
    Preconditions.checkNotNull(exceptions);
    callback.onLoadFailed(new GlideException("Fetch failed", new ArrayList<>(exceptions)));
  }
}
项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testIsFailedAfterException() {
  SingleRequest<List> request = builder.build();

  request.onLoadFailed(new GlideException("test"));
  assertTrue(request.isFailed());
}
项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testIsFailedAfterNoResultAndNullException() {
  SingleRequest<List> request = builder.build();

  request.onLoadFailed(new GlideException("test"));
  assertTrue(request.isFailed());
}
项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testErrorDrawableIsSetOnLoadFailed() {
  Drawable expected = new ColorDrawable(Color.RED);

  MockTarget target = new MockTarget();

  SingleRequest<List> request = builder
      .setErrorDrawable(expected)
      .setTarget(target)
      .build();

  request.onLoadFailed(new GlideException("test"));

  assertThat(target.currentPlaceholder).isEqualTo(expected);
}
项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testIsNotRunningAfterFailing() {
  SingleRequest<List> request = builder.build();
  request.begin();
  request.onLoadFailed(new GlideException("test"));

  assertFalse(request.isRunning());
}
项目:GitHub    文件:SingleRequestTest.java   
@Test
public void testCallsTargetOnExceptionIfNoRequestListener() {
  SingleRequest<List> request = builder
      .setRequestListener(null)
      .build();
  request.onLoadFailed(new GlideException("test"));

  verify(builder.target).onLoadFailed(eq(builder.errorDrawable));
}
项目:GitHub    文件:SingleRequestTest.java   
@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));
}
项目:GitHub    文件:SingleRequestTest.java   
@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));
}
项目:GitHub    文件:SingleRequestTest.java   
@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));
}
项目:ViewPagerHelper    文件:GlideManager.java   
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
    if (mBitmapListener != null){
        mBitmapListener.onFailure(e);
    }
    return false;
}
项目:glide-support    文件:LoggingListener.java   
@Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<R> target,
        boolean isFirstResource) {
    android.util.Log.println(level, "GLIDE", String.format(Locale.ROOT,
            "%s.onLoadFailed(%s, %s, %s, %s)\n%s",
            name, e, model, strip(target), isFirst(isFirstResource), android.util.Log.getStackTraceString(e)));
    return delegate.onLoadFailed(e, model, target, isFirstResource);
}
项目:BaseProject    文件:ProgressManager.java   
@Override
public void onProgress(String imageUrl, long bytesRead, long totalBytes, boolean isDone, GlideException exception) {
    if (listeners == null || listeners.size() == 0) return;

    for (int i = 0; i < listeners.size(); i++) {
        WeakReference<OnProgressListener> listener = listeners.get(i);
        OnProgressListener progressListener = listener.get();
        if (progressListener == null) {
            listeners.remove(i);
        } else {
            progressListener.onProgress(imageUrl, bytesRead, totalBytes, isDone, exception);
        }
    }
}
项目:BaseProject    文件:GlideImageLoader.java   
private void mainThreadCallback(final long bytesRead, final long totalBytes, final boolean isDone, final GlideException exception) {
    mMainThreadHandler.post(new Runnable() {
        @Override
        public void run() {
            final int percent = (int) ((bytesRead * 1.0f / totalBytes) * 100.0f);
            if (onProgressListener != null) {
                onProgressListener.onProgress((String) mImageUrlObj, bytesRead, totalBytes, isDone, exception);
            }

            if (onGlideImageViewListener != null) {
                onGlideImageViewListener.onProgress(percent, isDone, exception);
            }
        }
    });
}
项目:GestureViews    文件:DemoGlideHelper.java   
@Override
public boolean onLoadFailed(@Nullable GlideException ex, Object model,
        Target<T> target, boolean isFirstResource) {
    if (listener != null) {
        listener.onError();
    }
    return false;
}
项目:GitHub    文件:SingleRequest.java   
/**
 * A callback method that should never be invoked directly.
 */
@Override
public void onLoadFailed(GlideException e) {
  onLoadFailed(e, Log.WARN);
}
项目:GitHub    文件:SingleRequestTest.java   
private static GlideException isAGlideException() {
  return isA(GlideException.class);
}
项目:GitHub    文件:GifDrawableTest.java   
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model,
    Target<T> target,
    boolean isFirstResource) {
  throw new RuntimeException(e);
}
项目:GitHub    文件:RequestFutureTarget.java   
GlideExecutionException(GlideException cause) {
  super();
  this.cause = cause;
}
项目:GitHub    文件:SingleRequest.java   
@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");
  }

  // If we're restarted after we're complete (usually via something like a notifyDataSetChanged
  // that starts an identical request into the same Target or View), we can simply use the
  // resource and size we retrieved the last time around and skip obtaining a new size, starting a
  // new load etc. This does mean that users who want to restart a load because they expect that
  // the view size has changed will need to explicitly clear the View or Target before starting
  // 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));
  }
}
项目:GitHub    文件:SingleRequest.java   
/**
 * A callback method that should never be invoked directly.
 */
@Override
public void onLoadFailed(GlideException e) {
  onLoadFailed(e, Log.WARN);
}
项目:GitHub    文件:SingleRequestTest.java   
private static GlideException isAGlideException() {
  return isA(GlideException.class);
}
项目:leisure-glance    文件:GalleryActivity.java   
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
    return false;
}
项目:ocreader    文件:FaviconLoader.java   
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Bitmap> target, boolean b) {
    Log.e(TAG, "Loading favicon for feed with id " + feedId + " failed", e);
    listener.onGenerated(new FeedColors((Integer)null));
    return false;
}
项目:glide-support    文件:NoOpRequestListener.java   
@Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<R> target,
        boolean isFirstResource) {
    return false;
}