aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core-ui/src/main/res-public/values/public.xml6
-rw-r--r--core/src/main/res-public/values/public.xml34
-rw-r--r--fastadapter-viewbinding/src/main/kotlin/ca/allanwang/fastadapter/viewbinding/BindingItem.kt22
3 files changed, 36 insertions, 26 deletions
diff --git a/core-ui/src/main/res-public/values/public.xml b/core-ui/src/main/res-public/values/public.xml
index c8c2e56..f62ed25 100644
--- a/core-ui/src/main/res-public/values/public.xml
+++ b/core-ui/src/main/res-public/values/public.xml
@@ -1,10 +1,10 @@
<resources xmlns:tools='http://schemas.android.com/tools' tools:ignore='ResourceName'>
<!-- AUTO-GENERATED FILE. DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task -->
- <public name='kau_recycler_detached_background' type='layout' />
- <public name='kau_elastic_recycler_activity' type='layout' />
- <public name='kau_recycler_textslider' type='layout' />
<public name='Kau.Translucent' type='style' />
<public name='Kau.Translucent.NoAnimation' type='style' />
<public name='Kau.Translucent.SlideBottom' type='style' />
<public name='Kau.Translucent.SlideTop' type='style' />
+ <public name='kau_recycler_detached_background' type='layout' />
+ <public name='kau_elastic_recycler_activity' type='layout' />
+ <public name='kau_recycler_textslider' type='layout' />
</resources> \ No newline at end of file
diff --git a/core/src/main/res-public/values/public.xml b/core/src/main/res-public/values/public.xml
index 9f8780e..a912019 100644
--- a/core/src/main/res-public/values/public.xml
+++ b/core/src/main/res-public/values/public.xml
@@ -1,20 +1,25 @@
<resources xmlns:tools='http://schemas.android.com/tools' tools:ignore='ResourceName'>
<!-- AUTO-GENERATED FILE. DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task -->
- <public name='kau_slide_in_top' type='anim' />
<public name='kau_slide_in_left' type='anim' />
- <public name='kau_slide_out_right' type='anim' />
+ <public name='kau_slide_out_left' type='anim' />
<public name='kau_slide_out_right_top' type='anim' />
- <public name='kau_fade_in' type='anim' />
- <public name='kau_slide_out_top' type='anim' />
- <public name='kau_slide_out_bottom' type='anim' />
<public name='kau_fade_out' type='anim' />
- <public name='kau_slide_out_left' type='anim' />
<public name='kau_slide_out_left_top' type='anim' />
+ <public name='kau_fade_in' type='anim' />
<public name='kau_slide_in_bottom' type='anim' />
<public name='kau_slide_in_right' type='anim' />
- <public name='kau_transparent' type='drawable' />
- <public name='kau_selectable_white' type='drawable' />
- <public name='kau_shadow_overlay' type='color' />
+ <public name='kau_slide_in_top' type='anim' />
+ <public name='kau_slide_out_top' type='anim' />
+ <public name='kau_slide_out_bottom' type='anim' />
+ <public name='kau_slide_out_right' type='anim' />
+ <public name='kau_enter_slide_right' type='transition' />
+ <public name='kau_exit_slide_right' type='transition' />
+ <public name='kau_exit_slide_top' type='transition' />
+ <public name='kau_enter_slide_bottom' type='transition' />
+ <public name='kau_enter_slide_left' type='transition' />
+ <public name='kau_exit_slide_left' type='transition' />
+ <public name='kau_enter_slide_top' type='transition' />
+ <public name='kau_exit_slide_bottom' type='transition' />
<public name='kau_activity_horizontal_margin' type='dimen' />
<public name='kau_activity_vertical_margin' type='dimen' />
<public name='kau_dialog_margin' type='dimen' />
@@ -99,6 +104,7 @@
<public name='kau_bullet_point' type='string' />
<public name='Kau' type='style' />
<public name='Kau.Translucent' type='style' />
+ <public name='kau_shadow_overlay' type='color' />
<public name='KauFadeIn' type='style' />
<public name='KauFadeInFadeOut' type='style' />
<public name='KauSlideInRight' type='style' />
@@ -106,12 +112,6 @@
<public name='KauSlideInFadeOut' type='style' />
<public name='KauSlideInSlideOutRight' type='style' />
<public name='KauSlideInSlideOutBottom' type='style' />
- <public name='kau_enter_slide_bottom' type='transition' />
- <public name='kau_enter_slide_top' type='transition' />
- <public name='kau_exit_slide_bottom' type='transition' />
- <public name='kau_exit_slide_top' type='transition' />
- <public name='kau_enter_slide_right' type='transition' />
- <public name='kau_exit_slide_right' type='transition' />
- <public name='kau_exit_slide_left' type='transition' />
- <public name='kau_enter_slide_left' type='transition' />
+ <public name='kau_transparent' type='drawable' />
+ <public name='kau_selectable_white' type='drawable' />
</resources> \ No newline at end of file
diff --git a/fastadapter-viewbinding/src/main/kotlin/ca/allanwang/fastadapter/viewbinding/BindingItem.kt b/fastadapter-viewbinding/src/main/kotlin/ca/allanwang/fastadapter/viewbinding/BindingItem.kt
index a475615..543a9ef 100644
--- a/fastadapter-viewbinding/src/main/kotlin/ca/allanwang/fastadapter/viewbinding/BindingItem.kt
+++ b/fastadapter-viewbinding/src/main/kotlin/ca/allanwang/fastadapter/viewbinding/BindingItem.kt
@@ -19,6 +19,8 @@ import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
import ca.allanwang.kau.fastadapter.viewbinding.R
@@ -40,8 +42,8 @@ interface BindingLayout<Binding : ViewBinding> {
}
abstract class BindingItem<Binding : ViewBinding>(open val data: Any?) :
- AbstractItem<BindingItem.ViewHolder>(),
- BindingLayout<Binding> {
+ AbstractItem<BindingItem.ViewHolder>(),
+ BindingLayout<Binding> {
override val type: Int
get() = layoutRes
@@ -62,6 +64,14 @@ abstract class BindingItem<Binding : ViewBinding>(open val data: Any?) :
abstract fun Binding.bindView(holder: ViewHolder, payloads: MutableList<Any>)
+ protected fun unbind(vararg textViews: TextView) {
+ textViews.forEach { it.text = null }
+ }
+
+ protected fun unbind(vararg imageViews: ImageView) {
+ imageViews.forEach { it.setImageDrawable(null) }
+ }
+
final override fun unbindView(holder: ViewHolder) {
super.unbindView(holder)
val binding = holder.getBinding<Binding>()
@@ -71,7 +81,7 @@ abstract class BindingItem<Binding : ViewBinding>(open val data: Any?) :
open fun Binding.unbindView(holder: ViewHolder) {}
final override fun getViewHolder(v: View): ViewHolder =
- ViewHolder(v, layoutRes)
+ ViewHolder(v, layoutRes)
override fun failedToRecycle(holder: ViewHolder): Boolean {
KL.e { "Failed to recycle" }
@@ -87,7 +97,7 @@ abstract class BindingItem<Binding : ViewBinding>(open val data: Any?) :
override fun hashCode(): Int = data.hashCode()
class ViewHolder(itemView: View, internal val layoutRes: Int) :
- RecyclerView.ViewHolder(itemView) {
+ RecyclerView.ViewHolder(itemView) {
/**
* Retrieves a binding.
@@ -109,7 +119,7 @@ abstract class BindingItem<Binding : ViewBinding>(open val data: Any?) :
}
abstract class BindingClickEventHook<Binding : ViewBinding, Item : BindingItem<Binding>>(val identifier: BindingLayout<Binding>) :
- ClickEventHook<Item>() {
+ ClickEventHook<Item>() {
private fun RecyclerView.ViewHolder.binding(): Binding? {
val holder = this as? BindingItem.ViewHolder ?: return null
@@ -136,7 +146,7 @@ abstract class BindingClickEventHook<Binding : ViewBinding, Item : BindingItem<B
}
open fun Binding.onBindMany(viewHolder: RecyclerView.ViewHolder): List<View>? =
- super.onBindMany(viewHolder)
+ super.onBindMany(viewHolder)
final override fun onClick(v: View, position: Int, fastAdapter: FastAdapter<Item>, item: Item) {
BindingItem.getBinding<Binding>(v).onClick(v, position, fastAdapter, item)