Last active
August 21, 2017 13:20
-
-
Save joecks/d90fe41e7d2f289c89fde45da0d5b7e0 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
// Listen to Single Event live-data object that will only report a snackbar message once | |
mTasksViewModel.getSnackbarMessage().observe(this, new SnackbarMessage.SnackbarObserver() { | |
@Override | |
public void onNewMessage(@StringRes int snackbarMessageResourceId) { | |
SnackbarUtils.showSnackbar(getView(), getString(snackbarMessageResourceId)); | |
} | |
}); | |
... | |
// Bind onItemClick onItemSelect to the view-model | |
ListView listView = mTasksFragBinding.tasksList; | |
mListAdapter = new TasksAdapter( | |
new ArrayList<Task>(0), | |
mTasksViewModel | |
); | |
listView.setAdapter(mListAdapter); | |
// bind view-model directly to the view | |
mTasksViewModel = TasksActivity.obtainViewModel(getActivity()); | |
mTasksFragBinding.setViewmodel(mTasksViewModel); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment