app/src/main/java/com/groupon/maygupta/imagesearch/activities/ImagesListActivity.java
// Append more data into the adapter
Append more data into the adapter
Append more data into the adapter
public void customLoadMoreDataFromApi(int offset) {
        client.page = offset;
        client.getImages(new JsonHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                JSONArray resultsJson = null;
                try {
                    resultsJson = response.getJSONObject("responseData").getJSONArray("results");
                    adapter.addAll(Image.fromJSONArray(resultsJson));
                    adapter.notifyDataSetChanged();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
    }
public void customLoadMoreDataFromApi ( int offset ) { client . page = offset ; client . getImages ( new JsonHttpResponseHandler ( ) { @ Override public void onSuccess ( int statusCode , Header [ ] headers , JSONObject response ) { JSONArray resultsJson = null ; try { resultsJson = response . getJSONObject ( "responseData" ) . getJSONArray ( "results" ) ; adapter . addAll ( Image . fromJSONArray ( resultsJson ) ) ; adapter . notifyDataSetChanged ( ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } } } ) ; }
Append more data into the adapter
Append more data into the adapter
// This method probably sends out a network request and appends new data items to your adapter. // Use the offset value and add it as a parameter to your API request to retrieve paginated data. // Deserialize API response and then construct new objects to append to the adapter