Open nowiwr01w opened 4 years ago
@nowiwr01 Used Datbinding to change the state of the view
@JvmStatic
@BindingAdapter(value = ["bind:favouriteChildView"])
fun bindFavouriteState(view: SmallBangView, childView: View) {
view.setOnClickListener {
if (view.isSelected) {
view.isSelected = false
} else {
view.isSelected = true
view.likeAnimation(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator?) {
super.onAnimationEnd(animation)
}
})
}
}
}
<xyz.hanks.library.bang.SmallBangView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
bind:favouriteChildView="@{favouriteChildView}">
<ImageView
android:id="@+id/favourite_child_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/favourite_selector_selected" />
</xyz.hanks.library.bang.SmallBangView>
`
`
Please, share with us, if it's possible.