From 50ae08ed8d8cfa711568e7b6c35f7efd1a8f08ef Mon Sep 17 00:00:00 2001 From: len Date: Thu, 21 Apr 2016 16:31:23 +0200 Subject: [PATCH] Back button now returns to library. Closes #252 --- .../java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 8bf7f0e38..ace323f7a 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 @@ -39,7 +39,7 @@ class MainActivity : BaseActivity() { supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp) if (Build.VERSION.SDK_INT >= 21) { - window.statusBarColor = android.R.color.transparent; + window.statusBarColor = android.R.color.transparent } // Set behavior of Navigation drawer @@ -73,6 +73,16 @@ class MainActivity : BaseActivity() { 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) { supportFragmentManager.beginTransaction() .replace(R.id.frame_container, fragment)