Fix #242. Minor changes

This commit is contained in:
len 2016-04-08 18:01:33 +02:00
parent 67c4781376
commit 72f029b57f
4 changed files with 6 additions and 16 deletions

View File

@ -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

View File

@ -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() {

View File

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

View File

@ -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) {