Last active
April 6, 2018 09:18
-
-
Save Ulop/b6ab7e2ac5ab255880d8dedb8ecfbe47 to your computer and use it in GitHub Desktop.
SlimAdapter injector factory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun personInjector(): SlimInjector<Person> = injector { view: View, person: Person -> | |
view.name.text = person.name | |
view.about.text = person.about | |
GlideApp.with(view) | |
.load(person.avatar) | |
.circleCrop() | |
.into(view.avatar) | |
view.setOnClickListener { | |
Toast.makeText( | |
it.context, "${person.name}!", | |
Toast.LENGTH_SHORT | |
).show() | |
} | |
} | |
fun otherPersonInjector(): SlimInjector<Person> = slimInjector { person: Person -> | |
text(R.id.name, person.name) | |
text(R.id.about, person.about) | |
with<ImageView>(R.id.avatar) { image -> | |
GlideApp.with(image) | |
.load(person.avatar) | |
.circleCrop() | |
.into(image) | |
} | |
clicked(R.id.root) { | |
Toast.makeText( | |
it.context, "${person.name}! Remembered?", | |
Toast.LENGTH_SHORT | |
).show() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment