Improve cache feature

This commit is contained in:
tom79 2019-08-23 09:29:30 +02:00
parent 694ebc19ee
commit 04896a4f3b
3 changed files with 11 additions and 11 deletions

View File

@ -133,7 +133,6 @@ public class DisplayBookmarksFragment extends Fragment implements OnRetrieveFeed
@Override
public void onClick(DialogInterface dialogConfirm, int which) {
new StatusCacheDAO(context, db).removeAllStatus(StatusCacheDAO.BOOKMARK_CACHE);
new StatusCacheDAO(context, db).removeAllStatus(StatusCacheDAO.STATUS_CACHE);
statuses = new ArrayList<>();
statuses.clear();
statusListAdapter = new StatusListAdapter(RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS, null, isOnWifi, statuses);

View File

@ -227,6 +227,8 @@ import static app.fedilab.android.activities.BaseMainActivity.mutedAccount;
import static app.fedilab.android.activities.BaseMainActivity.regex_home;
import static app.fedilab.android.activities.BaseMainActivity.regex_local;
import static app.fedilab.android.activities.BaseMainActivity.regex_public;
import static app.fedilab.android.sqlite.StatusCacheDAO.ARCHIVE_CACHE;
import static app.fedilab.android.sqlite.StatusCacheDAO.BOOKMARK_CACHE;
import static com.koushikdutta.async.util.StreamUtility.copyStream;
import static app.fedilab.android.activities.BaseMainActivity.filters;
@ -3992,27 +3994,22 @@ public class Helper {
new TimelineCacheDAO(contextReference.get(), db).removeAll();
}
if( cache_owntoots.isChecked()){
new StatusCacheDAO(contextReference.get(), db).removeAll(ARCHIVE_CACHE);
}
if( cache_bookmarks.isChecked()){
new StatusCacheDAO(contextReference.get(), db).removeAll(BOOKMARK_CACHE);
}
}else{
if( cache_timeline.isChecked()){
new TimelineCacheDAO(contextReference.get(), db).removeAllConnected();
}
if( cache_owntoots.isChecked()){
new StatusCacheDAO(contextReference.get(), db).removeAllStatus(ARCHIVE_CACHE);
}
if( cache_bookmarks.isChecked()){
new StatusCacheDAO(contextReference.get(), db).removeAllStatus(BOOKMARK_CACHE);
}
}
/* Date date = new Date( System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1));
String dateString = Helper.dateToString(date);
new TimelineCacheDAO(contextReference.get(), db).removeAfterDate(dateString);*/
} catch (Exception ignored) {
}
}

View File

@ -48,7 +48,7 @@ public class StatusCacheDAO {
//Type of cache
public static int BOOKMARK_CACHE = 0;
public static int ARCHIVE_CACHE = 1;
public static int STATUS_CACHE = 2;
public StatusCacheDAO(Context context, SQLiteDatabase db) {
//Creation of the DB with tables
@ -216,6 +216,10 @@ public class StatusCacheDAO {
return db.delete(Sqlite.TABLE_STATUSES_CACHE, Sqlite.COL_CACHED_ACTION + " = \""+ cacheType +"\" AND " + Sqlite.COL_INSTANCE + " = '" + instance+ "' AND " + Sqlite.COL_USER_ID + " = '" + userId+ "'", null);
}
public int removeAll(int cacheType){
return db.delete(Sqlite.TABLE_STATUSES_CACHE, Sqlite.COL_CACHED_ACTION + " = \""+ cacheType +"\"", null);
}
//------- GETTERS -------
/**