Back button now returns to library. Closes #252
This commit is contained in:
parent
5385642a5b
commit
50ae08ed8d
1 changed files with 11 additions and 1 deletions
|
@ -39,7 +39,7 @@ class MainActivity : BaseActivity() {
|
||||||
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp)
|
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp)
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
window.statusBarColor = android.R.color.transparent;
|
window.statusBarColor = android.R.color.transparent
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set behavior of Navigation drawer
|
// Set behavior of Navigation drawer
|
||||||
|
@ -73,6 +73,16 @@ class MainActivity : BaseActivity() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
supportFragmentManager.findFragmentById(R.id.frame_container)?.let {
|
||||||
|
if (it !is LibraryFragment) {
|
||||||
|
setFragment(LibraryFragment.newInstance())
|
||||||
|
} else {
|
||||||
|
super.onBackPressed()
|
||||||
|
}
|
||||||
|
} ?: super.onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
fun setFragment(fragment: Fragment) {
|
fun setFragment(fragment: Fragment) {
|
||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.beginTransaction()
|
||||||
.replace(R.id.frame_container, fragment)
|
.replace(R.id.frame_container, fragment)
|
||||||
|
|
Reference in a new issue