Explorar o código

Fix #242. Minor changes

len %!s(int64=9) %!d(string=hai) anos
pai
achega
72f029b57f

+ 4 - 12
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

+ 1 - 1
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() {

+ 0 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt

@@ -143,8 +143,6 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
     }
 
     override fun onBackPressed() {
-        if (isFinishing) return
-
         presenter.onChapterLeft()
 
         val chapterToUpdate = presenter.getMangaSyncChapterToUpdate()

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt

@@ -99,7 +99,7 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
 
         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) {