Guest User

Untitled

a guest
May 25th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. class ToolbarNBottombarTemplateLayout<A : Activity>(private val layoutInterface: ToolbarNBottombarTemplateLayoutInterface) : AnkoComponent<A> {
  2.  
  3. var binding: ViewDataBinding? = null
  4.  
  5. override fun createView(ui: AnkoContext<A>): View {
  6. return ui.constraintLayout {
  7.  
  8. val toolbar = themedToolbar(layoutInterface.toolbarStyleId())
  9. toolbar.layoutParams = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT,
  10. ConstraintLayout.LayoutParams.WRAP_CONTENT)
  11.  
  12. val included = include<View>(layoutInterface.includedLayoutId()) {
  13. id = View.generateViewId()
  14. }
  15. binding = DataBindingUtil.bind(included)
  16.  
  17. val footer = themedTextView(layoutInterface.footerStyleId())
  18. footer.layoutParams = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT,
  19. ConstraintLayout.LayoutParams.WRAP_CONTENT)
  20.  
  21. constraintSet {
  22. connect(toolbar.id,
  23. android.support.constraint.ConstraintSet.TOP,
  24. ConstraintSet.PARENT_ID,
  25. android.support.constraint.ConstraintSet.TOP)
  26.  
  27. connect(footer.id,
  28. android.support.constraint.ConstraintSet.BOTTOM,
  29. ConstraintSet.PARENT_ID,
  30. android.support.constraint.ConstraintSet.BOTTOM)
  31.  
  32. connect(included.id,
  33. android.support.constraint.ConstraintSet.TOP,
  34. toolbar.id,
  35. android.support.constraint.ConstraintSet.BOTTOM)
  36. connect(included.id,
  37. android.support.constraint.ConstraintSet.BOTTOM,
  38. footer.id,
  39. android.support.constraint.ConstraintSet.TOP)
  40. }.applyTo(this)
  41. }
  42. }
  43.  
  44. interface ToolbarNBottombarTemplateLayoutInterface {
  45. fun toolbarStyleId(): Int
  46. fun includedLayoutId(): Int
  47. fun footerStyleId(): Int
  48. }
  49. }
Add Comment
Please, Sign In to add comment