Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class FRFragment : Fragment() {
- private var wasAdded: Boolean = false
- fun wasAdded(): Boolean {
- return wasAdded
- }
- fun setWasAdded(wasAdded: Boolean) {
- this.wasAdded = wasAdded
- }
- val fragmentName = "UNKNOWN FRAGMENT"
- abstract fun toolbarText(): String?
- @LayoutRes
- private val layoutId: Int
- init {
- layoutId = init()
- }
- @LayoutRes
- abstract fun init(): Int
- abstract fun setupView(rootView: View)
- override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
- val rootView = inflater!!.inflate(layoutId, null)
- ButterKnife.setDebug(true)
- ButterKnife.bind(this, rootView)
- val appbarlayoutfix = rootView.findViewById(R.id.appbarlayoutfix)
- val toolbar = rootView.findViewById(R.id.toolbar) as Toolbar?
- appbarlayoutfix?.setPadding(0, statusBarHeight, 0, 0)
- (toolbar?.findViewById(R.id.main_toolbar_title) as TextView?)?.text = toolbarText()
- toolbar?.findViewById(R.id.btn_toolbar_back)?.setOnClickListener { v -> FRFragmentManager.goBack() }
- setupView(rootView)
- return rootView
- }
- val statusBarHeight: Int
- get() {
- var result = 0
- val resourceId = context.resources.getIdentifier("status_bar_height", "dimen", "android")
- if (resourceId > 0) {
- result = context.resources.getDimensionPixelSize(resourceId)
- }
- return result
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement