New sources tip
parent
eec750789d
commit
9e56766e9e
@ -0,0 +1,27 @@
|
|||||||
|
package org.koitharu.kotatsu.list.ui.adapter
|
||||||
|
|
||||||
|
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
|
||||||
|
import org.koitharu.kotatsu.core.ui.widgets.TipView
|
||||||
|
import org.koitharu.kotatsu.databinding.ItemTip2Binding
|
||||||
|
import org.koitharu.kotatsu.list.ui.model.ListModel
|
||||||
|
import org.koitharu.kotatsu.list.ui.model.TipModel
|
||||||
|
|
||||||
|
fun tipAD(
|
||||||
|
listener: TipView.OnButtonClickListener,
|
||||||
|
) = adapterDelegateViewBinding<TipModel, ListModel, ItemTip2Binding>(
|
||||||
|
{ layoutInflater, parent -> ItemTip2Binding.inflate(layoutInflater, parent, false) }
|
||||||
|
) {
|
||||||
|
|
||||||
|
binding.root.onButtonClickListener = listener
|
||||||
|
|
||||||
|
bind {
|
||||||
|
with(binding.root) {
|
||||||
|
tag = item
|
||||||
|
setTitle(item.title)
|
||||||
|
setText(item.text)
|
||||||
|
setIcon(item.icon)
|
||||||
|
setPrimaryButtonText(item.primaryButtonText)
|
||||||
|
setSecondaryButtonText(item.secondaryButtonText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package org.koitharu.kotatsu.list.ui.model
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
|
||||||
|
class TipModel(
|
||||||
|
val key: String,
|
||||||
|
@StringRes val title: Int,
|
||||||
|
@StringRes val text: Int,
|
||||||
|
@DrawableRes val icon: Int,
|
||||||
|
@StringRes val primaryButtonText: Int,
|
||||||
|
@StringRes val secondaryButtonText: Int,
|
||||||
|
) : ListModel {
|
||||||
|
|
||||||
|
override fun areItemsTheSame(other: ListModel): Boolean {
|
||||||
|
return other is TipModel && other.key == key
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (javaClass != other?.javaClass) return false
|
||||||
|
|
||||||
|
other as TipModel
|
||||||
|
|
||||||
|
if (key != other.key) return false
|
||||||
|
if (title != other.title) return false
|
||||||
|
if (text != other.text) return false
|
||||||
|
if (icon != other.icon) return false
|
||||||
|
if (primaryButtonText != other.primaryButtonText) return false
|
||||||
|
return secondaryButtonText == other.secondaryButtonText
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = key.hashCode()
|
||||||
|
result = 31 * result + title
|
||||||
|
result = 31 * result + text
|
||||||
|
result = 31 * result + icon
|
||||||
|
result = 31 * result + primaryButtonText
|
||||||
|
result = 31 * result + secondaryButtonText
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<size
|
||||||
|
android:width="8dp"
|
||||||
|
android:height="8dp" />
|
||||||
|
</shape>
|
||||||
Loading…
Reference in New Issue