Skip to content

Instantly share code, notes, and snippets.

@shahbazahmed1269
Last active September 21, 2017 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shahbazahmed1269/9b4a2b727469997cfe1b27ec6425a907 to your computer and use it in GitHub Desktop.
Save shahbazahmed1269/9b4a2b727469997cfe1b27ec6425a907 to your computer and use it in GitHub Desktop.
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mViewModel = ViewModelProviders.of(this).get(ListIssuesViewModel.class);
setupView();
// Handle changes emitted by LiveData
mViewModel.getRes().observe(this, apiResponse -> {
if (apiResponse.getError() != null) {
handleError(apiResponse.getError());
} else {
handleResponse(apiResponse.getIssues());
}
});
}
// Rest of the code
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment