From 161b741d04c502eb39de49f4a2edf35740cf90b0 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 28 Apr 2020 16:47:18 -0400 Subject: [PATCH] No longer using chapter url for new chapter notification's reader intent --- .../java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt | 9 ++------- .../eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt | 9 --------- .../kanade/tachiyomi/util/chapter/ChapterSourceSync.kt | 9 ++++++--- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 52c3de5c1a..92d3681790 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -157,7 +157,6 @@ class ReaderActivity : BaseRxActivity(), val intent = Intent(context, ReaderActivity::class.java) intent.putExtra("manga", manga.id) intent.putExtra("chapter", chapter.id) - intent.putExtra("chapterUrl", chapter.url) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) return intent } @@ -188,17 +187,13 @@ class ReaderActivity : BaseRxActivity(), if (presenter.needsInit()) { val manga = intent.extras!!.getLong("manga", -1) val chapter = intent.extras!!.getLong("chapter", -1) - val chapterUrl = intent.extras!!.getString("chapterUrl", "") - if (manga == -1L || chapterUrl == "" && chapter == -1L) { + if (manga == -1L || chapter == -1L) { finish() return } NotificationReceiver.dismissNotification(this, manga.hashCode(), Notifications.ID_NEW_CHAPTERS) - when (chapter > -1) { - true -> presenter.init(manga, chapter) - false -> presenter.init(manga, chapterUrl) - } + presenter.init(manga, chapter) } if (savedInstanceState != null) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 63eea1037b..7583b97606 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -206,15 +206,6 @@ class ReaderPresenter( return chapterItems } - fun init(mangaId: Long, chapterUrl: String) { - if (!needsInit()) return - val context = Injekt.get() - val db = DatabaseHelper(context) - val chapterId = db.getChapter(chapterUrl, mangaId).executeAsBlocking()?.id - if (chapterId != null) - init(mangaId, chapterId) - } - /** * Initializes this presenter with the given [manga] and [initialChapterId]. This method will * set the chapter loader, view subscriptions and trigger an initial load. diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt index 168dc94e03..4776dd7fff 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt @@ -126,7 +126,10 @@ fun syncChaptersWithSource( readded.add(c) } } - db.insertChapters(toAdd).executeAsBlocking() + val chapters = db.insertChapters(toAdd).executeAsBlocking() + toAdd.forEach { chapter -> + chapter.id = chapters.results().getValue(chapter).insertedId() + } } if (toChange.isNotEmpty()) { @@ -137,8 +140,8 @@ fun syncChaptersWithSource( db.fixChaptersSourceOrder(sourceChapters).executeAsBlocking() // Set this manga as updated since chapters were changed - val newestChatper = db.getChapters(manga).executeAsBlocking().maxBy { it.date_upload } - val dateFetch = newestChatper?.date_upload ?: manga.last_update + val newestChapter = db.getChapters(manga).executeAsBlocking().maxBy { it.date_upload } + val dateFetch = newestChapter?.date_upload ?: manga.last_update if (dateFetch == 0L) { if (toAdd.isNotEmpty()) manga.last_update = Date().time