Last active
July 11, 2017 12:18
-
-
Save clackbib/26ae484f67b8f4c2fc8f3614ddfdd407 to your computer and use it in GitHub Desktop.
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
data class User( | |
val id: String, | |
val name: String, | |
val profilePicUrl: String, | |
val bio: String) |
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
public class UserFragment : Fragment() { | |
private lateinit var vm: UserViewModel | |
private lateinit var bin: Disposable | |
private lateinit var tvTitle: TextView | |
private lateinit var tvDescription: TextView | |
private lateinit var ivPicture: ImageView | |
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
bin = vm.user() | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe({ user -> | |
tvTitle.text = user.name | |
tvDescription.text = user.bio | |
Glide.with(context).load(user.profilePicUrl) | |
.into(ivPicture) | |
}) | |
} | |
override fun onDestroyView() { | |
super.onDestroyView() | |
bin.dispose() | |
} | |
} |
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
public class UserViewModel { | |
private lateinit var repo: Repository | |
fun user(): Observable<User> { | |
return repo.loadUser() | |
.subscribeOn(Schedulers.io()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment