Skip to content

Commit

Permalink
Modify Example for new api
Browse files Browse the repository at this point in the history
  • Loading branch information
amitshekhariitbhu committed Mar 19, 2017
1 parent 006d901 commit 7276335
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ ANRequest request = AndroidNetworking.get("https://fierce-cove-29863.herokuapp.c
.addPathParameter("pageNumber", "0")
.addQueryParameter("limit", "3")
.build();
ANResponse<List<User>> response = request.executeForParsed(new TypeToken<List<User>>() {});
ANResponse<List<User>> response = request.executeForObjectList(User.class);
if (response.isSuccess()) {
List<User> users = responseTwo.getResult();
} else {
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/com/networking/ApiTestActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.androidnetworking.interfaces.OkHttpResponseListener;
import com.androidnetworking.interfaces.ParsedRequestListener;
import com.androidnetworking.interfaces.UploadProgressListener;
import com.google.gson.reflect.TypeToken;
import com.networking.model.User;
import com.networking.utils.Utils;

Expand Down Expand Up @@ -1013,8 +1012,7 @@ public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceive
Log.d(TAG, " isFromCache : " + isFromCache);
}
});
ANResponse<List<User>> responseTwo = requestTwo.executeForParsed(new TypeToken<List<User>>() {
});
ANResponse<List<User>> responseTwo = requestTwo.executeForObjectList(User.class);

if (responseTwo.isSuccess()) {
Log.d(TAG, "checkSynchronousCall : response success");
Expand Down
11 changes: 3 additions & 8 deletions app/src/main/java/com/networking/OkHttpResponseTestActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@
import com.androidnetworking.interfaces.AnalyticsListener;
import com.androidnetworking.interfaces.DownloadListener;
import com.androidnetworking.interfaces.DownloadProgressListener;
import com.androidnetworking.interfaces.JSONObjectRequestListener;
import com.androidnetworking.interfaces.OkHttpResponseAndJSONArrayRequestListener;
import com.androidnetworking.interfaces.OkHttpResponseAndJSONObjectRequestListener;
import com.androidnetworking.interfaces.OkHttpResponseAndParsedRequestListener;
import com.androidnetworking.interfaces.OkHttpResponseListener;
import com.androidnetworking.interfaces.UploadProgressListener;
import com.google.gson.reflect.TypeToken;
import com.networking.model.User;
import com.networking.utils.Utils;

Expand Down Expand Up @@ -123,8 +121,7 @@ public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceive
Log.d(TAG, " isFromCache : " + isFromCache);
}
})
.getAsOkHttpResponseAndParsed(new TypeToken<List<User>>() {
}, new OkHttpResponseAndParsedRequestListener<List<User>>() {
.getAsOkHttpResponseAndObjectList(User.class, new OkHttpResponseAndParsedRequestListener<List<User>>() {
@Override
public void onResponse(Response okHttpResponse, List<User> users) {
Log.d(TAG, "userList size : " + users.size());
Expand Down Expand Up @@ -163,8 +160,7 @@ public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceive
Log.d(TAG, " isFromCache : " + isFromCache);
}
})
.getAsOkHttpResponseAndParsed(new TypeToken<User>() {
}, new OkHttpResponseAndParsedRequestListener<User>() {
.getAsOkHttpResponseAndObject(User.class, new OkHttpResponseAndParsedRequestListener<User>() {
@Override
public void onResponse(Response okHttpResponse, User user) {
Log.d(TAG, "id : " + user.id);
Expand Down Expand Up @@ -964,8 +960,7 @@ public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceive
Log.d(TAG, " isFromCache : " + isFromCache);
}
});
ANResponse<List<User>> responseTwo = requestTwo.executeForParsed(new TypeToken<List<User>>() {
});
ANResponse<List<User>> responseTwo = requestTwo.executeForObjectList(User.class);

if (responseTwo.isSuccess()) {
Log.d(TAG, "checkSynchronousCall : response success");
Expand Down

0 comments on commit 7276335

Please sign in to comment.