Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Support binding from custom classes #74

Closed
wants to merge 1 commit into from
Closed

Support binding from custom classes #74

wants to merge 1 commit into from

Conversation

SUPERCILEX
Copy link

@JakeWharton elegantly fixes #43, fixes #10, fixes #6, fixes #42, fixes #9

All other previous solutions require extra work from the client whereas this solution uses a somewhat naughty hack to make life easy. Example use:

class AuthHelper(activity: Activity) {
    private val rootView: View by activity.bindView(R.id.root)
}

This implementation stores a strong reference to the context (which is fine since bindView should only be used in classes properly tied to the lifecycle anyway) by keeping the extension function's reference. In previous versions, the extension type was only used to not overload the different bindView methods, but we now use that context.

@SUPERCILEX
Copy link
Author

I'm using JetBrains' Kotlin extensions now. It's disappointing to have never received a response. 🤷‍♂️

@SUPERCILEX SUPERCILEX closed this Apr 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bind view in arbitrary class Support ViewHolder pattern
1 participant