Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unbind extension to ItemViewBindingEpoxyHolder #1223

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
buildscript {

ext.KOTLIN_VERSION = "1.4.32"
ext.ANDROID_PLUGIN_VERSION = '7.0.0-beta03'
ext.ANDROID_PLUGIN_VERSION = '7.0.0'

repositories {
google()
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ abstract class ViewBindingEpoxyModelWithHolder<in T : ViewBinding> :

abstract fun T.bind()

@Suppress("UNCHECKED_CAST")
override fun unbind(holder: ViewBindingHolder) {
(holder.viewBinding as T).unbind()
}

open fun T.unbind() {}

override fun createNewHolder(parent: ViewParent): ViewBindingHolder {
return ViewBindingHolder(this::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ abstract class ItemViewBindingEpoxyHolder : ViewBindingEpoxyModelWithHolder<View
title.text = [email protected]
title.setOnClickListener { listener() }
}

override fun ViewBindingHolderItemBinding.unbind() {
// Don't leak listeners as this view goes back to the view pool
title.setOnClickListener(null)
}
}