switch to LRU cache

This commit is contained in:
Andrew Dolgov 2015-07-11 00:15:20 +03:00
parent 013b4fa616
commit e0e85a2e7b
2 changed files with 19 additions and 7 deletions

View File

@ -20,6 +20,7 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.nostra13.universalimageloader.core.ImageLoader;
import org.fox.ttrss.types.Article; import org.fox.ttrss.types.Article;
import org.fox.ttrss.types.ArticleList; 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) { public void onFeedSelected(Feed feed, final boolean selectedByUser) {
ImageLoader.getInstance().clearMemoryCache();
FragmentTransaction ft = getSupportFragmentManager() FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction(); .beginTransaction();

View File

@ -32,10 +32,10 @@ import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken; 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.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.utils.StorageUtils;
import org.fox.ttrss.offline.OfflineActivity; import org.fox.ttrss.offline.OfflineActivity;
import org.fox.ttrss.offline.OfflineDownloadService; import org.fox.ttrss.offline.OfflineDownloadService;
@ -50,6 +50,7 @@ import org.jsoup.nodes.Document;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -168,12 +169,20 @@ public class OnlineActivity extends CommonActivity {
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
if (!ImageLoader.getInstance().isInited()) { if (!ImageLoader.getInstance().isInited()) {
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) ImageLoaderConfiguration config;
try {
config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.diskCache( .diskCache(
new UnlimitedDiscCache(new File(StorageUtils.getCacheDirectory(getApplicationContext()), "article-images"))) new LruDiscCache(new File(getCacheDir(), "article-images"),
DefaultConfigurationFactory.createFileNameGenerator(),
100 * 1024 * 1024))
.build(); .build();
} catch (IOException e) {
config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.build();
}
ImageLoader.getInstance().init(config); ImageLoader.getInstance().init(config);
ImageLoader.getInstance().clearDiskCache();
} }
//m_pullToRefreshAttacher = PullToRefreshAttacher.get(this); //m_pullToRefreshAttacher = PullToRefreshAttacher.get(this);