Skip to content

Instantly share code, notes, and snippets.

@enginebai
Created December 8, 2020 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enginebai/79c62e4a4ec89f069d672fa43c1e6cb7 to your computer and use it in GitHub Desktop.
Save enginebai/79c62e4a4ec89f069d672fa43c1e6cb7 to your computer and use it in GitHub Desktop.
MovieHunt blog part5. epoxy model custom view sample
@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT)
class DropdownItemView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {
@TextProp
var itemText: CharSequence? = null
@ModelProp
fun selected(selected: Boolean = false) {
textMenuItem.isSelected = selected
}
@CallbackProp
var clickListener: OnClickListener? = null
private val textMenuItem: TextView
init {
View.inflate(context, R.layout.item_dropdown_menu, this)
orientation = VERTICAL
textMenuItem = findViewById(R.id.textMenu)
}
@AfterPropsSet
fun userProps() {
textMenuItem.text = itemText
textMenuItem.setOnClickListener(clickListener)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment