Skip to content

Commit

Permalink
🐛 Fix bugs in the memory cache when decodeGifImage is on
Browse files Browse the repository at this point in the history
  • Loading branch information
Flyge committed Nov 3, 2017
1 parent e10fd45 commit 481d194
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/logs/log_2.6.0_p1.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* :hammer: HttpStack.ImageHttpResponse.getResponseHeadersString() 重命名为 HttpStack.Response.getHeadersString()
* :hammer: HttpStack.ImageHttpResponse.getResponseHeader() 重命名为 HttpStack.Response.getHeader()
* :hammer: ImageAttrs 从 drawable 中移动到 decode 包中
* :bug: 修复开启解码 gif 后内存缓存失效的 bug

sample app:
* :bug: 修复 UNSPLASH 页面没有加载完数据就切换到别的页面时崩溃的 BUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ private void saveParams() {
}

private boolean checkMemoryCache() {
if (displayOptions.isCacheInMemoryDisabled() || displayOptions.isDecodeGifImage()) {
if (displayOptions.isCacheInMemoryDisabled()) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected void runLoad() {
}

// Check memory cache
if (!displayOptions.isCacheInDiskDisabled() && !displayOptions.isDecodeGifImage()) {
if (!displayOptions.isCacheInDiskDisabled()) {
setStatus(Status.CHECK_MEMORY_CACHE);
MemoryCache memoryCache = getConfiguration().getMemoryCache();
SketchRefBitmap cachedRefBitmap = memoryCache.get(getMemoryCacheKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String getDisplayFreeRideKey() {
}

/**
* 可以坐顺风车?条件是内存缓存key一样并且内存缓存可以用,没有单独关闭内存缓存,不解码GIF图片的请求,没有开同步执行,请求执行器可以用
* 可以坐顺风车?条件是内存缓存 key 一样并且内存缓存可以用,没有单独关闭内存缓存,不解码 gif 图片,没有开同步执行,请求执行器可以用
*/
@Override
public boolean canByDisplayFreeRide() {
Expand Down Expand Up @@ -109,7 +109,7 @@ public Set<FreeRideManager.DisplayFreeRide> getDisplayFreeRideSet() {

@Override
public synchronized boolean processDisplayFreeRide() {
if (!getOptions().isCacheInDiskDisabled() && !getOptions().isDecodeGifImage()) {
if (!getOptions().isCacheInDiskDisabled()) {
MemoryCache memoryCache = getConfiguration().getMemoryCache();
SketchRefBitmap cachedRefBitmap = memoryCache.get(getMemoryCacheKey());
if (cachedRefBitmap != null && cachedRefBitmap.isRecycled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ public String makeKey() {
if (inPreferQualityOverSpeed) {
builder.append("_").append("preferQuality");
}
if (decodeGifImage) {
builder.append("_").append("decodeGifImage");
}
if (bitmapConfig != null) {
builder.append("_").append(bitmapConfig.name());
}
Expand Down

0 comments on commit 481d194

Please sign in to comment.