Add set read cache max size
This commit is contained in:
1 parent
6d9ed41382
commit
56cfc0669b
9 files changed
+43
-1
No files matched your search
@@ -822,6 +822,13 @@ public class Settings {
|
||||
putString(KEY_SECURITY, value);
|
||||
}
|
||||
|
||||
public static final String KEY_READ_CACHE_SIZE = "read_cache_size";
|
||||
public static final int DEFAULT_READ_CACHE_SIZE = 160;
|
||||
|
||||
public static int getReadCacheSize() {
|
||||
return getIntFromStr(KEY_READ_CACHE_SIZE, DEFAULT_READ_CACHE_SIZE);
|
||||
}
|
||||
|
||||
/********************
|
||||
****** Guide
|
||||
********************/
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.hippo.unifile.FilenameFilter;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.yorozuya.FileUtils;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
import com.hippo.yorozuya.Utilities;
|
||||
import com.hippo.yorozuya.io.InputStreamPipe;
|
||||
import com.hippo.yorozuya.io.OutputStreamPipe;
|
||||
@@ -54,7 +55,8 @@ public final class SpiderDen {
|
||||
private static SimpleDiskCache sCache;
|
||||
|
||||
public static void initialize(Context context) {
|
||||
sCache = new SimpleDiskCache(new File(context.getCacheDir(), "image"), 160 * 1024 * 1024);
|
||||
sCache = new SimpleDiskCache(new File(context.getCacheDir(), "image"),
|
||||
MathUtils.clamp(Settings.getReadCacheSize(), 40, 640) * 1024 * 1024);
|
||||
}
|
||||
|
||||
private static class StartWithFilenameFilter implements FilenameFilter {
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.support.annotation.ArrayRes;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
@@ -139,6 +140,9 @@ public class ListPreference extends DialogPreference {
|
||||
* @param value The value to set for the key.
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
|
||||
Log.d("TAG", "value = " + value);
|
||||
|
||||
// Always persist/notify the first time.
|
||||
final boolean changed = !TextUtils.equals(mValue, value);
|
||||
if (changed || !mValueSet) {
|
||||
|
||||
Reference in new issue
Block a user