Created
June 29, 2019 21:04
-
-
Save psteiger/afa29c2d7c5077ca46b4e275d3bd4213 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class UserFragment : Fragment() { | |
| private var usersViewModel: UserViewModel? = null | |
| override fun onCreateView( | |
| inflater: LayoutInflater, | |
| container: ViewGroup?, | |
| savedInstanceState: Bundle? | |
| ): View? = inflater.inflate(R.layout.fragment_users, container, false) | |
| override fun onViewCreated( | |
| view: View, | |
| savedInstanceState: Bundle? | |
| ) { | |
| usersViewModel = ViewModelProviders | |
| .of(this) | |
| .get(UsersViewModel::class.java) | |
| usersViewModel.usersLiveData.observe(viewLifecycleOwner, Observer { resource -> | |
| resource.onSuccess { userList: HashMap<String, User> -> | |
| usersLoaded(user) | |
| }.onLoading { partialUserList: HashMap<String, User> -> | |
| usersAreLoading(partialUserList) | |
| // show ProgressBar? | |
| }.onFailure { cause: Throwable -> | |
| userLoadFailed(cause) | |
| } | |
| }) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment