Last active
June 2, 2017 03:04
-
-
Save nottyo/83fad435237d5d375b16868de4cf2138 to your computer and use it in GitHub Desktop.
LoadingActivity.java
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
private AsyncHttpClient asyncHttpClient; | |
public class LoadingActivity extends Activity { | |
private CountingIdlingResource idlingResource = EspressoIdlingResource.getCountingIdlingResource(); | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activiy_loading_screen); | |
asyncHttpClient = new AsyncHttpClient(); | |
// increment the counter before calling any API. | |
idlingResource.increment(); | |
asyncHttpClient.get(LoadingActivity.this, url, configurationCallback); | |
} | |
private JsonHttpResponseHandler configurationCallback = = new JsonHttpResponseHandler() { | |
@Override | |
public void onSuccess(int statusCode, Header[] headers, JSONObject jsonObject) { | |
// decrement the counter when callback is invoked. | |
idlingResource.decrement(); | |
Intent intent = new Intent(LoadingActivity.this, MainActivity.class); | |
startActivity(intent); | |
} | |
} | |
} | |
@VisibleForTesting | |
public IdlingResource getCountingIdlingResource(){ | |
return EspressoIdlingResource.getCountingIdlingResource(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment