Group notifcations for Library updates (#2582)
This commit is contained in:
@@ -19,6 +19,8 @@ import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
||||
@@ -104,10 +106,14 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
const val VERTICAL = 3
|
||||
const val WEBTOON = 4
|
||||
|
||||
fun newIntent(context: Context, manga: Manga, chapter: Chapter): Intent {
|
||||
fun newIntent(context: Context, manga: Manga, chapter: Chapter):
|
||||
Intent {
|
||||
val intent = Intent(context, ReaderActivity::class.java)
|
||||
intent.putExtra("manga", manga.id)
|
||||
intent.putExtra("chapter", chapter.id)
|
||||
// chapters just added from library updates don't have an id yet
|
||||
intent.putExtra("chapterUrl", chapter.url)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
return intent
|
||||
}
|
||||
}
|
||||
@@ -126,13 +132,14 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
if (presenter.needsInit()) {
|
||||
val manga = intent.extras!!.getLong("manga", -1)
|
||||
val chapter = intent.extras!!.getLong("chapter", -1)
|
||||
|
||||
if (manga == -1L || chapter == -1L) {
|
||||
val chapterUrl = intent.extras!!.getString("chapterUrl", "")
|
||||
if (manga == -1L || chapterUrl == "" && chapter == -1L) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
presenter.init(manga, chapter)
|
||||
NotificationReceiver.dismissNotification(this, manga.hashCode(), Notifications.ID_NEW_CHAPTERS)
|
||||
if (chapter > -1) presenter.init(manga, chapter)
|
||||
else presenter.init(manga, chapterUrl)
|
||||
}
|
||||
|
||||
if (savedState != null) {
|
||||
|
||||
@@ -185,6 +185,19 @@ class ReaderPresenter(
|
||||
}, ReaderActivity::setInitialChapterError)
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes this presenter with the given [mangaId] and [chapterUrl]. This method will
|
||||
* fetch the manga from the database and initialize the initial chapter.
|
||||
*/
|
||||
fun init(mangaId: Long, chapterUrl: String) {
|
||||
if (!needsInit()) return
|
||||
val context = Injekt.get<Application>()
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user