Last active
July 16, 2018 18:14
-
-
Save catalinghita8/0ac5ecaf2024c03f14195f707cd6ff00 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
public void loadData() { | |
// The network request might be handled in a different thread so make sure Espresso knows | |
// that the app is busy until the response is handled. | |
EspressoIdlingResource.increment(); // App is busy until further notice | |
// let's get the data | |
mRepository.getData(new LoadDataCallback() { | |
@Override | |
public void onDataLoaded(Data data) { | |
// now that the data has been loaded, we can mark the app as idle | |
// first, make sure the app is still marked as busy then decrement, there might be cases | |
// when other components finished their asynchronous tasks and marked the app as idle | |
if (!EspressoIdlingResource.getIdlingResource().isIdleNow()) { | |
EspressoIdlingResource.decrement(); // Set app as idle. | |
} | |
processData(data); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment