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

Support binding from custom classes - #74

Closed
SUPERCILEX wants to merge 1 commit into
JakeWharton:masterfrom
SUPERCILEX:custom
Closed

Support binding from custom classes#74
SUPERCILEX wants to merge 1 commit into
JakeWharton:masterfrom
SUPERCILEX:custom

Conversation

@SUPERCILEX

Copy link
Copy Markdown

@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.

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@SUPERCILEX

Copy link
Copy Markdown
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