Refactor history with room paging

This commit is contained in:
tarsin committed 2022-08-12 15:29:04 +08:00
1 parent c5977e358e
commit 1c38f77b5c
3 files changed
+399 -548

No files matched your search

@@ -22,6 +22,7 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.paging.PagingSource;
import androidx.room.Room;
import com.hippo.ehviewer.client.data.GalleryInfo;
@@ -326,10 +327,14 @@ public class EhDB {
dao.update(list);
}
public static synchronized List<HistoryInfo> getHistoryLazyList() {
public static synchronized List<HistoryInfo> getHistoryList() {
return db.historyDao().list();
}
public static synchronized PagingSource<Integer, HistoryInfo> getHistoryLazyList() {
return db.historyDao().listLazy();
}
public static synchronized void putHistoryInfo(GalleryInfo galleryInfo) {
HistoryDao dao = db.historyDao();
HistoryInfo info = dao.load(galleryInfo.gid);
@@ -1,5 +1,6 @@
package com.hippo.ehviewer.dao;
import androidx.paging.PagingSource;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
@@ -19,6 +20,9 @@ public interface HistoryDao extends BasicDao<HistoryInfo> {
@Query("SELECT * FROM HISTORY ORDER BY TIME DESC LIMIT :limit OFFSET :offset")
List<HistoryInfo> list(int offset, int limit);
@Query("SELECT * FROM HISTORY ORDER BY TIME DESC")
PagingSource<Integer, HistoryInfo> listLazy();
@Update
void update(HistoryInfo historyInfo);
File diff suppressed because it is too large. Load diff