Skip to content

Commit

Permalink
optimize ErrorCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
panpengfei committed Jun 4, 2016
1 parent 051e766 commit a316229
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public static DecodeResult decodeFromHelper(LoadRequest loadRequest, DecodeHelpe
error.printStackTrace();
ErrorCallback errorCallback = loadRequest.getSketch().getConfiguration().getErrorCallback();
if (errorCallback != null) {
boundsOptions.inSampleSize = decodeOptions.inSampleSize;
errorCallback.onDecodeNormalImageFailed(error, loadRequest, boundsOptions);
}
}
Expand Down
16 changes: 12 additions & 4 deletions sketch/src/main/java/me/xiaopan/sketch/feature/ErrorCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void onInstallDiskCacheFailed(Exception e, File cacheDir) {
Log.e(Sketch.TAG, SketchUtils.concat(logName, " - ", "InstallDiskCacheFailed", ": ", e.getMessage(), " - ", cacheDir.getPath()));
}

public void onDecodeGifImageFailed(Throwable error, LoadRequest request, BitmapFactory.Options options) {
public void onDecodeGifImageFailed(Throwable error, LoadRequest request, BitmapFactory.Options boundsOptions) {
if (error instanceof UnsatisfiedLinkError || error instanceof ExceptionInInitializerError) {
Log.e(Sketch.TAG, "Didn't find “libpl_droidsonroids_gif.so” file, " +
"unable to process the GIF images. If you need to decode the GIF figure " +
Expand All @@ -38,10 +38,14 @@ public void onDecodeGifImageFailed(Throwable error, LoadRequest request, BitmapF
Log.e(Sketch.TAG, SketchUtils.concat("Didn't find libpl_droidsonroids_gif.so. ", abiInfo));
}

Log.e(Sketch.TAG, SketchUtils.concat(logName, " - ", "DecodeGifImageFailed", ": ", request.getAttrs().getId()));
Log.e(Sketch.TAG, SketchUtils.concat(logName,
" - ", "DecodeGifImageFailed",
" - ", "outWidth", "=", boundsOptions.outWidth, ", ", "outHeight", "=", boundsOptions.outHeight, ", " +
"", "outMimeType", "=", boundsOptions.outMimeType,
" - ", request.getAttrs().getId()));
}

public void onDecodeNormalImageFailed(Throwable error, LoadRequest request, BitmapFactory.Options options) {
public void onDecodeNormalImageFailed(Throwable error, LoadRequest request, BitmapFactory.Options boundsOptions) {
if (error instanceof OutOfMemoryError) {
long maxMemory = Runtime.getRuntime().maxMemory();
long freeMemory = Runtime.getRuntime().freeMemory();
Expand All @@ -56,7 +60,11 @@ public void onDecodeNormalImageFailed(Throwable error, LoadRequest request, Bitm
"totalMemory", "=", totalMemoryFormatted));
}

Log.e(Sketch.TAG, SketchUtils.concat(logName, " - ", "DecodeNormalImageFailed", ": ", request.getAttrs().getId()));
Log.e(Sketch.TAG, SketchUtils.concat(logName,
" - ", "DecodeNormalImageFailed",
" - ", "outWidth", "=", boundsOptions.outWidth, ", ", "outHeight", "=", boundsOptions.outHeight, ", " +
"", "outMimeType", "=", boundsOptions.outMimeType,
" - ", request.getAttrs().getId()));
}

@Override
Expand Down

0 comments on commit a316229

Please sign in to comment.