forked from panpf/sketch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📝 Rewrite the wiki and optimize the code
- Loading branch information
Flyge
committed
Sep 17, 2017
1 parent
5518f69
commit c4452e7
Showing
51 changed files
with
774 additions
and
552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
# 使用 cacheProcessedImageInDisk 属性缓存需要复杂处理的图片,提升显示速度 | ||
|
||
一张图片要经过读取(或缩略图模式读取)和ImageProcessor处理才能显示在页面上,这两步通常也是整个显示过程中最耗时的,为了加快显示速度,减少用户等待时间我们可以将最终经过inSampleSize缩小的、缩略图模式读取的或ImageProcessor处理过的图片缓存在磁盘中,下次就可以直接读取 | ||
一张图片要经过读取(或缩略图模式读取)和 ImageProcessor 处理才能显示在页面上,这两步通常也是整个显示过程中最耗时的,为了加快显示速度,减少用户等待时间我们可以将最终经过 inSampleSize 缩小的、缩略图模式读取的或 [ImageProcessor] 处理过的图片缓存在磁盘中,下次就可以读取后直接使用 | ||
|
||
#### 如何开启: | ||
### 如何开启: | ||
|
||
```java | ||
DisplayOptions displayOptions = new DisplayOptions(); | ||
|
||
displayOptions.setCacheProcessedImageInDisk(true); | ||
``` | ||
|
||
#### 使用条件 | ||
### 使用条件 | ||
|
||
并不是你只要开启了就一定会将最终的图片缓存在磁盘缓存中,还需要满足以下任一条件: | ||
>* 有maxSize并且最终计算得出的inSampleSize大于等于8 | ||
>* 有resize | ||
>* 有ImageProcessor,并且确实生成了一张新的图片 | ||
>* thumbnailMode为true并且resize不为null | ||
* 有 maxSize 并且最终计算得出的 inSampleSize 大于等于 8 | ||
* 有 resize | ||
* 有 ImageProcessor,并且确实生成了一张新的图片 | ||
* thumbnailMode 为 true 并且 resize 不为 null | ||
|
||
#### 存在的问题 | ||
### 存在的问题 | ||
|
||
由于Android天然存在的BUG,导致读到内存里的图片,再保存到磁盘后图片会发生轻微的色彩变化(通常是发黄),因此在使用此功能时还是要慎重考虑此因素带来的影响 | ||
由于 Android 天然存在的 BUG,导致读到内存里的图片,再保存到磁盘后图片会发生轻微的色彩变化(通常是发黄并丢失一些细节),因此在使用此功能时还是要慎重考虑此因素带来的影响,参考文章 [Android 中 decode JPG 时建议使用 inPreferQualityOverSpeed][reference_article] | ||
|
||
参考文章:http://www.cnblogs.com/zhucai/p/inPreferQualityOverSpeed.html | ||
`此功能读取图片时已强制设置 inPreferQualityOverSpeed 为 true` | ||
|
||
`此功能读取图片时已强制设置inPreferQualityOverSpeed为true` | ||
[ImageProcessor]:../../sketch/src/main/java/me/xiaopan/sketch/process/ImageProcessor.java | ||
[reference_article]: http://www.cnblogs.com/zhucai/p/inPreferQualityOverSpeed.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
# 取消显示图片 | ||
# 取消请求 | ||
|
||
Sketch会自动取消请求,因此你不必刻意关注怎么去取消一个请求,或者该在什么时候去取消一个请求 | ||
### display 显示请求 | ||
|
||
#### 什么时候会自动取消请求? | ||
>* SketchImageView重用的时候会自动取消之前的请求 | ||
>* SketchImageView在onDetachedFromWindow的时候也会自动取消请求 | ||
display 显示请求 [Sketch] 会在合适的时候自动取消,如下: | ||
* [SketchImageView] 重用的时候会自动取消旧的未完成的请求 | ||
* [SketchImageView] 在 onDetachedFromWindow 的时候自动取消未完成的请求 | ||
|
||
#### 如何主动取消请求? | ||
>* 方法1:在执行commit()或SketchImageView.display***Image()方法之后你会得到一个Request, | ||
你可以通过Request的isCanceled()方法查看请求是否结束会或通过Request的cancel()方法取消请求 | ||
>* 方法2:你可以通过Sketch.cancel(SketchView)方法来取消请求 | ||
因此你不必刻意关注怎么去取消一个显示请求 | ||
|
||
``取消请求的时候如果正在读取数据,就会立马停止读取,已经读取的数据就算浪费了`` | ||
但有时候你还是想知道如何主动取消显示请求? | ||
1. 在执行 [DisplayHelper].commit() 或 [SketchImageView].display***Image() 方法之后你会得到一个 [DisplayRequest],通过其 cancel() 方法可以取消显示请求 | ||
2. 你还可以通过 [Sketch].cancel(SketchView) 方法来取消显示请求 | ||
|
||
``取消请求的时候如果正在下载图片,就会立马停止下载,已经下载的数据就算浪费了`` | ||
|
||
### load 加载请求 | ||
|
||
在执行 [LoadHelper].commit() 方法之后你会得到一个 [LoadRequest],通过其 cancel() 方法可以取消显示请求 | ||
|
||
### download 下载请求 | ||
|
||
在执行 [DownloadHelper].commit() 方法之后你会得到一个 [DownloadRequest],通过其 cancel() 方法可以取消显示请求 | ||
|
||
[Sketch]: ../../sketch/src/main/java/me/xiaopan/sketch/Sketch.java | ||
[SketchImageView]: ../../sketch/src/main/java/me/xiaopan/sketch/SketchImageView.java | ||
[DisplayHelper]:../../sketch/src/main/java/me/xiaopan/sketch/request/DisplayHelper.java | ||
[DisplayRequest]:../../sketch/src/main/java/me/xiaopan/sketch/request/DisplayRequest.java | ||
[LoadHelper]:../../sketch/src/main/java/me/xiaopan/sketch/request/LoadHelper.java | ||
[LoadRequest]:../../sketch/src/main/java/me/xiaopan/sketch/request/LoadRequest.java | ||
[DownloadHelper]:../../sketch/src/main/java/me/xiaopan/sketch/request/DownloadHelper.java | ||
[DownloadRequest]:../../sketch/src/main/java/me/xiaopan/sketch/request/DownloadRequest.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.