Last active
August 21, 2017 06:42
-
-
Save piotrmadry/6d6e179920ac48b57f7d50fc33292c5a 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 FragmentToolbar(@IdRes val resId: Int, | |
@StringRes val title: Int, | |
@MenuRes val menuId: Int, | |
val menuItems: MutableList<Int>, | |
val menuClicks: MutableList<MenuItem.OnMenuItemClickListener?>) { | |
companion object { | |
@JvmField val NO_TOOLBAR = -1 | |
} | |
class Builder { | |
private var resId: Int = -1 | |
private var menuId: Int = -1 | |
private var title: Int = -1 | |
private var menuItems: MutableList<Int> = mutableListOf() | |
private var menuClicks: MutableList<MenuItem.OnMenuItemClickListener?> = mutableListOf() | |
fun withId(@IdRes resId: Int) = apply { this.resId = resId } | |
fun withTitle(title: Int) = apply { this.title = title } | |
fun withMenu(@MenuRes menuId: Int) = apply { this.menuId = menuId } | |
fun withMenuItems(menuItems: MutableList<Int>, menuClicks: MutableList<MenuItem.OnMenuItemClickListener?>) = apply { | |
this.menuItems.addAll(menuItems) | |
this.menuClicks.addAll(menuClicks) | |
} | |
fun build() = FragmentToolbar(resId, title, menuId, menuItems, menuClicks) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment