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
| data class SchemeRouter(@IdRes val destinationId: Int, val `moreOptions`: Any) | |
| data class SchemeCommand(val routers: List<SchemeRouter>, val `moreOptions`: Any) |
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
| private val recyclerViewState = SubmittableRecyclerViewState( | |
| object : DiffUtil.ItemCallback<AntonioUiModel>() { | |
| override fun areItemsTheSame(oldItem: AntonioUiModel, newItem: AntonioUiModel) = | |
| oldItem.id == newItem.id | |
| override fun areContentsTheSame(oldItem: AntonioUiModel, newItem: AntonioUiModel) = | |
| oldItem == newItem | |
| }) | |
| override fun onCreate(savedInstanceState: Bundle?) { |
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
| sealed class AntonioUiModel( | |
| val type: Type, | |
| open val id: Long, | |
| open val price: Int | |
| ) : AntonioBindingModel { | |
| enum class Type { MONITOR, MOUSE, PHONE } | |
| override fun bindingVariableId(): Int = BR.item | |
| data class Monitor(override val id: Long, override val price: Int, val inch: Float) : |
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
| dependencies { | |
| // https://github.com/naverz/Antonio | |
| implementation "io.github.naverz:antonio-databinding:1.0.3-alpha" | |
| implementation "io.github.naverz:antonio-annotation:0.0.1-alpha" | |
| kapt "io.github.naverz:antonio-annotation:0.0.1-alpha" | |
| } |
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
| private val adapter by lazy { | |
| DataBindingAdapter<NormalUiModel>( | |
| bindingVariableId = BR.item, | |
| variables = mapOf(BR.onNormalListener to onNormalListener), | |
| object : DiffUtil.ItemCallback<BindingItem<NormalUiModel>>() { | |
| override fun areItemsTheSame( | |
| oldItem: BindingItem<NormalUiModel>, newItem: BindingItem<NormalUiModel> | |
| ) = oldItem.item.id == newItem.item.id | |
| override fun areContentsTheSame( |
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
| data class BindingItem<ITEM>(@LayoutRes val type: Int, val item: ITEM) | |
| fun <T> T.toBindingItem(@LayoutRes type: Int): BindingItem<T> { | |
| return BindingItem(type, this) | |
| } |
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
| private val adapter by lazy { NormalAdapter(onNormalListener) } | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| binding.recyclerView.adapter = adapter | |
| viewModel.uiModels.observe(this) { | |
| adapter.submitList(it) | |
| } | |
| } |
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
| class NormalAdapter( | |
| private val onNormalListener: OnNormalListener | |
| ) : ListAdapter<NormalUiModel, BindViewHolder<NormalUiModel>>( | |
| object : DiffUtil.ItemCallback<NormalUiModel>() { | |
| override fun areItemsTheSame(oldItem: NormalUiModel, newItem: NormalUiModel) = | |
| oldItem.id == newItem.id | |
| override fun areContentsTheSame(oldItem: NormalUiModel, newItem: NormalUiModel) = | |
| oldItem == newItem | |
| } |
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
| <layout | |
| xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| > | |
| <data> | |
| <variable | |
| name="item" |
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
| interface OnNormalListener { | |
| fun onClicked(item: NormalUiModel) | |
| } |
NewerOlder