Minor cleanup

This commit is contained in:
arkon
2020-02-17 11:30:13 -05:00
parent 3b334c4230
commit 497fe1e68a
7 changed files with 50 additions and 47 deletions

View File

@@ -138,9 +138,10 @@ class MainActivity : BaseActivity() {
private fun handleIntentAction(intent: Intent): Boolean {
val notificationId = intent.getIntExtra("notificationId", -1)
if (notificationId > -1) NotificationReceiver.dismissNotification(
applicationContext, notificationId, intent.getIntExtra("groupId", 0)
)
if (notificationId > -1) {
NotificationReceiver.dismissNotification(applicationContext, notificationId, intent.getIntExtra("groupId", 0))
}
when (intent.action) {
SHORTCUT_LIBRARY -> setSelectedDrawerItem(R.id.nav_drawer_library)
SHORTCUT_RECENTLY_UPDATED -> setSelectedDrawerItem(R.id.nav_drawer_recent_updates)

View File

@@ -106,15 +106,14 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
const val VERTICAL = 3
const val WEBTOON = 4
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
fun newIntent(context: Context, manga: Manga, chapter: Chapter): Intent {
return Intent(context, ReaderActivity::class.java).apply {
putExtra("manga", manga.id)
putExtra("chapter", chapter.id)
// chapters just added from library updates don't have an id yet
putExtra("chapterUrl", chapter.url)
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
}
}

View File

@@ -191,11 +191,13 @@ class ReaderPresenter(
*/
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)
if (chapterId != null) {
init(mangaId, chapterId)
}
}
/**