From f6efbd4b9cf1f441a13fc0856004e4da5831c541 Mon Sep 17 00:00:00 2001 From: Alexander Eggers Date: Mon, 18 Mar 2019 15:26:05 +1100 Subject: [PATCH] Tweaking code --- .../archtree/fragment/ArchTreeFragment.kt | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/builder/src/main/java/archtree/fragment/ArchTreeFragment.kt b/builder/src/main/java/archtree/fragment/ArchTreeFragment.kt index 8f0436f..431dfae 100644 --- a/builder/src/main/java/archtree/fragment/ArchTreeFragment.kt +++ b/builder/src/main/java/archtree/fragment/ArchTreeFragment.kt @@ -64,26 +64,17 @@ abstract class ArchTreeFragment : Fragment(), Injecta val toolbarTitle = fragmentResource?.toolbarTitle if (toolbarViewId != null && activity != null && activity is AppCompatActivity) { - if (fragmentResource.activityToolbar) { - activity.setSupportActionBar(activity.findViewById(toolbarViewId)) - } else { - activity.setSupportActionBar(rootView?.findViewById(toolbarViewId)) - } + if (fragmentResource.activityToolbar) activity.setSupportActionBar(activity.findViewById(toolbarViewId)) + else activity.setSupportActionBar(rootView?.findViewById(toolbarViewId)) val displayHomeAsUpEnabled = fragmentResource.displayHomeAsUpEnabled activity.supportActionBar?.setDisplayHomeAsUpEnabled(displayHomeAsUpEnabled) - if (toolbarTitle != null) { - activity.supportActionBar?.title = toolbarTitle - } + if (toolbarTitle != null) activity.supportActionBar?.title = toolbarTitle val toolbarIcon = fragmentResource.toolbarIcon - if (toolbarIcon != null) { - activity.supportActionBar?.setIcon(toolbarIcon) - } - } else if (toolbarTitle != null) { - activity?.title = toolbarTitle - } + if (toolbarIcon != null) activity.supportActionBar?.setIcon(toolbarIcon) + } else if (toolbarTitle != null) activity?.title = toolbarTitle } override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { @@ -135,9 +126,7 @@ abstract class ArchTreeFragment : Fragment(), Injecta this.menu = menu val menuId = fragmentResource?.menuId - if (menuId != null) { - activity?.menuInflater?.inflate(menuId, menu) - } + if (menuId != null) activity?.menuInflater?.inflate(menuId, menu) return getViewModel()?.onCreateOptionsMenu(menu) ?: false }