From 382acab118dfd251bf7989822efa8d756b6e6544 Mon Sep 17 00:00:00 2001 From: inorichi Date: Mon, 30 Nov 2015 21:08:06 +0100 Subject: [PATCH] Add a query to get the next unread chapter --- .../mangafeed/data/database/DatabaseHelper.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java b/app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java index 49e579af8e..b75af7fb9a 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java @@ -226,6 +226,21 @@ public class DatabaseHelper { .prepare(); } + public PreparedGetListOfObjects getNextUnreadChapter(Manga manga) { + return db.get() + .listOfObjects(Chapter.class) + .withQuery(Query.builder() + .table(ChapterTable.TABLE) + .where(ChapterTable.COLUMN_MANGA_ID + "=? AND " + + ChapterTable.COLUMN_READ + "=? AND " + + ChapterTable.COLUMN_CHAPTER_NUMBER + ">=?") + .whereArgs(manga.id, 0, 0) + .orderBy(ChapterTable.COLUMN_CHAPTER_NUMBER) + .limit(1) + .build()) + .prepare(); + } + public PreparedPutObject insertChapter(Chapter chapter) { return db.put() .object(chapter)