Last active
August 21, 2017 06:42
-
-
Save piotrmadry/7da5298ac47ca1eee93877a1a64588f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ToolbarManager constructor( | |
private var builder: FragmentToolbar, | |
private var container: View) { | |
fun prepareToolbar() { | |
if (builder.resId != FragmentToolbar.NO_TOOLBAR) { | |
val fragmentToolbar = container.findViewById(builder.resId) as Toolbar | |
if (builder.title != -1) { | |
fragmentToolbar.setTitle(builder.title) | |
} | |
if (builder.menuId != -1) { | |
fragmentToolbar.inflateMenu(builder.menuId) | |
} | |
if (!builder.menuItems.isEmpty() && !builder.menuClicks.isEmpty()){ | |
val menu = fragmentToolbar.menu | |
for ((index, menuItemId) in builder.menuItems.withIndex()) { | |
(menu.findItem(menuItemId) as MenuItem).setOnMenuItemClickListener(builder.menuClicks[index]) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment