Created
December 8, 2020 14:43
-
-
Save enginebai/79c62e4a4ec89f069d672fa43c1e6cb7 to your computer and use it in GitHub Desktop.
MovieHunt blog part5. epoxy model custom view sample
This file contains hidden or 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
@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