Use Application object instead of explicit Context

This commit is contained in:
Anthony Restaino 2016-01-24 00:20:31 -05:00
parent 600034b6fa
commit f73f82030f

View File

@ -94,7 +94,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
mSearchSubtitle = mContext.getString(R.string.suggestion); mSearchSubtitle = mContext.getString(R.string.suggestion);
mDarkTheme = dark || incognito; mDarkTheme = dark || incognito;
mIncognito = incognito; mIncognito = incognito;
Thread delete = new Thread(new ClearCacheRunnable(context)); Thread delete = new Thread(new ClearCacheRunnable(BrowserApp.get(context)));
mSearchDrawable = ThemeUtils.getThemedDrawable(context, R.drawable.ic_search, mDarkTheme); mSearchDrawable = ThemeUtils.getThemedDrawable(context, R.drawable.ic_search, mDarkTheme);
mBookmarkDrawable = ThemeUtils.getThemedDrawable(context, R.drawable.ic_bookmark, mDarkTheme); mBookmarkDrawable = ThemeUtils.getThemedDrawable(context, R.drawable.ic_bookmark, mDarkTheme);
mHistoryDrawable = ThemeUtils.getThemedDrawable(context, R.drawable.ic_history, mDarkTheme); mHistoryDrawable = ThemeUtils.getThemedDrawable(context, R.drawable.ic_history, mDarkTheme);
@ -209,15 +209,15 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
private static class ClearCacheRunnable implements Runnable { private static class ClearCacheRunnable implements Runnable {
private Context context; private Application app;
public ClearCacheRunnable(Context context) { public ClearCacheRunnable(Application app) {
this.context = BrowserApp.get(context); this.app = app;
} }
@Override @Override
public void run() { public void run() {
File dir = new File(context.getCacheDir().toString()); File dir = new File(app.getCacheDir().toString());
String[] fileList = dir.list(new NameFilter()); String[] fileList = dir.list(new NameFilter());
long earliestTimeAllowed = System.currentTimeMillis() - INTERVAL_DAY; long earliestTimeAllowed = System.currentTimeMillis() - INTERVAL_DAY;
for (String fileName : fileList) { for (String fileName : fileList) {