diff options
author | Andrew Dolgov <[email protected]> | 2015-07-11 00:15:20 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2015-07-11 00:15:20 +0300 |
commit | e0e85a2e7b1801aae24105c8547306ae6c334bb6 (patch) | |
tree | 9f5ce9165d3f21b22ad6447f33ae3a73c2d0e51d | |
parent | 013b4fa616b3bfa6024e6627ee4e9b76a9e8733f (diff) |
switch to LRU cache
-rw-r--r-- | org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java | 3 | ||||
-rwxr-xr-x | org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java | 23 |
2 files changed, 19 insertions, 7 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java index 908c839a..38064fbd 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java @@ -20,6 +20,7 @@ import android.view.MenuItem; import android.view.View; import com.google.gson.JsonElement; +import com.nostra13.universalimageloader.core.ImageLoader; import org.fox.ttrss.types.Article; import org.fox.ttrss.types.ArticleList; @@ -230,6 +231,8 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList public void onFeedSelected(Feed feed, final boolean selectedByUser) { + ImageLoader.getInstance().clearMemoryCache(); + FragmentTransaction ft = getSupportFragmentManager() .beginTransaction(); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java index 05b458c6..8d337b26 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java @@ -32,10 +32,10 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; -import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache; +import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiscCache; +import com.nostra13.universalimageloader.core.DefaultConfigurationFactory; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; -import com.nostra13.universalimageloader.utils.StorageUtils; import org.fox.ttrss.offline.OfflineActivity; import org.fox.ttrss.offline.OfflineDownloadService; @@ -50,6 +50,7 @@ import org.jsoup.nodes.Document; import org.jsoup.select.Elements; import java.io.File; +import java.io.IOException; import java.lang.reflect.Type; import java.util.HashMap; import java.util.List; @@ -168,12 +169,20 @@ public class OnlineActivity extends CommonActivity { setSupportActionBar(toolbar); if (!ImageLoader.getInstance().isInited()) { - ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) - .diskCache( - new UnlimitedDiscCache(new File(StorageUtils.getCacheDirectory(getApplicationContext()), "article-images"))) - .build(); + ImageLoaderConfiguration config; + + try { + config = new ImageLoaderConfiguration.Builder(getApplicationContext()) + .diskCache( + new LruDiscCache(new File(getCacheDir(), "article-images"), + DefaultConfigurationFactory.createFileNameGenerator(), + 100 * 1024 * 1024)) + .build(); + } catch (IOException e) { + config = new ImageLoaderConfiguration.Builder(getApplicationContext()) + .build(); + } ImageLoader.getInstance().init(config); - ImageLoader.getInstance().clearDiskCache(); } //m_pullToRefreshAttacher = PullToRefreshAttacher.get(this); |