Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
Tweaking code
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderEggers committed Mar 18, 2019
1 parent 6a97605 commit f6efbd4
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions builder/src/main/java/archtree/fragment/ArchTreeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,17 @@ abstract class ArchTreeFragment<ViewModel : BaseViewModel> : 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<out String>, grantResults: IntArray) {
Expand Down Expand Up @@ -135,9 +126,7 @@ abstract class ArchTreeFragment<ViewModel : BaseViewModel> : 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
}
Expand Down

0 comments on commit f6efbd4

Please sign in to comment.