Toggle reader menu with the menu button, closes #286. Fix incorrect drawer selected item when using back button

This commit is contained in:
len 2016-05-01 21:53:00 +02:00
parent 49628e9cf5
commit 1d1e5f1f99
4 changed files with 16 additions and 14 deletions

View file

@ -76,7 +76,8 @@ class MainActivity : BaseActivity() {
override fun onBackPressed() {
supportFragmentManager.findFragmentById(R.id.frame_container)?.let {
if (it !is LibraryFragment) {
setFragment(LibraryFragment.newInstance())
nav_view.setCheckedItem(R.id.nav_drawer_library)
nav_view.menu.performIdentifierAction(R.id.nav_drawer_library, 0)
} else {
super.onBackPressed()
}

View file

@ -201,21 +201,22 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
return true
}
}
KeyEvent.KEYCODE_DPAD_RIGHT -> {
if (event.action == KeyEvent.ACTION_UP) {
viewer?.moveToNext()
}
}
KeyEvent.KEYCODE_DPAD_LEFT -> {
if (event.action == KeyEvent.ACTION_UP) {
viewer?.moveToPrevious()
}
}
}
}
return super.dispatchKeyEvent(event)
}
override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
if (!isFinishing) {
when (keyCode) {
KeyEvent.KEYCODE_DPAD_RIGHT -> viewer?.moveToNext()
KeyEvent.KEYCODE_DPAD_LEFT -> viewer?.moveToPrevious()
KeyEvent.KEYCODE_MENU -> toggleMenu()
}
}
return super.onKeyUp(keyCode, event)
}
fun onChapterError(error: Throwable) {
Timber.e(error, error.message)
finish()
@ -318,7 +319,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
}
}
fun onCenterSingleTap() {
fun toggleMenu() {
setMenuVisibility(reader_menu.visibility == View.GONE)
}

View file

@ -168,7 +168,7 @@ abstract class PagerReader : BaseReader() {
} else if (positionX > pager.width * RIGHT_REGION) {
if (tappingEnabled) onRightSideTap()
} else {
readerActivity.onCenterSingleTap()
readerActivity.toggleMenu()
}
return true
}

View file

@ -130,7 +130,7 @@ class WebtoonReader : BaseReader() {
} else if (positionX > recycler.width * RIGHT_REGION) {
if (tappingEnabled) moveToNext()
} else {
readerActivity.onCenterSingleTap()
readerActivity.toggleMenu()
}
return true
}