From 72f029b57f8acdd72e7536174ab81cabbac56d1e Mon Sep 17 00:00:00 2001 From: len Date: Fri, 8 Apr 2016 18:01:33 +0200 Subject: [PATCH] Fix #242. Minor changes --- .../tachiyomi/ui/base/activity/BaseActivity.kt | 16 ++++------------ .../eu/kanade/tachiyomi/ui/main/MainActivity.kt | 2 +- .../kanade/tachiyomi/ui/reader/ReaderActivity.kt | 2 -- .../tachiyomi/ui/reader/ReaderPresenter.kt | 2 +- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt index ed41051a13..c616f66cd8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt @@ -4,7 +4,6 @@ import android.graphics.Color import android.support.design.widget.Snackbar import android.support.v7.app.AppCompatActivity import android.support.v7.widget.Toolbar -import android.view.MenuItem import android.view.View import android.widget.TextView import eu.kanade.tachiyomi.App @@ -12,9 +11,12 @@ import eu.kanade.tachiyomi.R open class BaseActivity : AppCompatActivity() { - protected fun setupToolbar(toolbar: Toolbar) { + protected fun setupToolbar(toolbar: Toolbar, backNavigation: Boolean = true) { setSupportActionBar(toolbar) supportActionBar?.setDisplayHomeAsUpEnabled(true) + if (backNavigation) { + toolbar.setNavigationOnClickListener { onBackPressed() } + } } fun setAppTheme() { @@ -40,16 +42,6 @@ open class BaseActivity : AppCompatActivity() { supportActionBar?.subtitle = getString(titleResource) } - override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { - android.R.id.home -> { - onBackPressed() - return true - } - } - return super.onOptionsItemSelected(item) - } - fun snack(text: String?, duration: Int = Snackbar.LENGTH_LONG) { val snack = Snackbar.make(findViewById(android.R.id.content)!!, text ?: getString(R.string.unknown_error), duration) val textView = snack.view.findViewById(android.support.design.R.id.snackbar_text) as TextView diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index bea488f3cf..ffe67cecaf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -37,7 +37,7 @@ class MainActivity : BaseActivity() { setContentView(R.layout.activity_main) // Handle Toolbar - setupToolbar(toolbar) + setupToolbar(toolbar, backNavigation = false) supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp) drawer.addDrawerListener(object : DrawerLayout.SimpleDrawerListener() { 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 5285c1164e..9a470a2539 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 @@ -143,8 +143,6 @@ class ReaderActivity : BaseRxActivity() { } override fun onBackPressed() { - if (isFinishing) return - presenter.onChapterLeft() val chapterToUpdate = presenter.getMangaSyncChapterToUpdate() 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 1a08cf1f82..8c6cc38a40 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 @@ -99,7 +99,7 @@ class ReaderPresenter : BasePresenter() { restartableLatestCache(GET_PAGE_LIST, { getPageListObservable(chapter) }, - { view, chapter -> view.onChapterReady(manga, chapter, currentPage) }, + { view, chapter -> view.onChapterReady(manga, this.chapter, currentPage) }, { view, error -> view.onChapterError(error) }) if (savedState == null) {