Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Handle Api call success and error listener.
/**
* Success listener to handle the movie listing
* process after api returns the movie list
*
* @return
*/
private Response.Listener<String> ReqSuccessListener() {
return new Response.Listener<String>() {
public void onResponse(String response) {
Log.e("movie list_response", response);
try {
hideProgress();
pageNumber++;
MovieList movieListModel = (MovieList) Utils.jsonToPojo(response, MovieList.class);
if (movieListModel.getResults() != null &&
movieListModel.getResults().size() > 0) {
moviesRecyclerAdapter.addMovies(movieListModel.getResults());
} else {
Log.e(TAG, "list empty==");
}
} catch (Exception e) {
Log.e(TAG,"Exception=="+e.getLocalizedMessage());
}
}
};
}
/**
* To Handle the error
*
* @return
*/
private Response.ErrorListener ReqErrorListener() {
return new Response.ErrorListener() {
public void onErrorResponse(VolleyError error) {
Log.e("volley error", "volley error");
Toast.makeText(MovieListingActivity.this, "" +
"Server Error..Please try again after sometime", Toast.LENGTH_SHORT).show();
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.