Last active
April 2, 2018 23:54
-
-
Save hkakutalua/d8fe52d11fcbe744b3c4dc8e0330d0c5 to your computer and use it in GitHub Desktop.
Creating and
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
| @Override | |
| public Loader<List<User>> onCreateLoader(int id, Bundle args) { | |
| return new AsyncTaskLoader<List<User>>(this) { | |
| List<User> users; | |
| @Override | |
| protected void onStartLoading() { | |
| super.onStartLoading(); | |
| if (users == null) { | |
| forceLoad(); | |
| } else { | |
| deliverResult(users); | |
| } | |
| } | |
| @Override | |
| public List<User> loadInBackground() { | |
| try { | |
| return mGithubService.getUsers().execute().body(); | |
| } catch (IOException e) { | |
| return null; | |
| } | |
| } | |
| @Override | |
| public void deliverResult(List<User> data) { | |
| super.deliverResult(data); | |
| users = data; | |
| } | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment