优化
This commit is contained in:
@@ -17,6 +17,8 @@ import io.legado.app.utils.isXml
|
|||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
import kotlin.math.max
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
object ImageProvider {
|
object ImageProvider {
|
||||||
|
|
||||||
@@ -27,10 +29,10 @@ object ImageProvider {
|
|||||||
/**
|
/**
|
||||||
*缓存bitmap LruCache实现
|
*缓存bitmap LruCache实现
|
||||||
*/
|
*/
|
||||||
//private val maxMemory = Runtime.getRuntime().maxMemory()
|
private const val M = 1024 * 1024
|
||||||
//private val cacheMemorySize = (maxMemory / 8) as Int
|
private val cacheSize =
|
||||||
private const val cacheMemorySize: Int = 1024 * 1024 * 1024 //1G
|
max(50 * M, min(100 * M, (Runtime.getRuntime().maxMemory() / 8).toInt()))
|
||||||
private val bitmapLruCache = object : LruCache<String, Bitmap>(cacheMemorySize) {
|
private val bitmapLruCache = object : LruCache<String, Bitmap>(cacheSize) {
|
||||||
override fun sizeOf(key: String, bitmap: Bitmap): Int {
|
override fun sizeOf(key: String, bitmap: Bitmap): Int {
|
||||||
return bitmap.byteCount
|
return bitmap.byteCount
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user