use of ctn.example.user.dvectn.POJO.ResPOJO in project DVECTN by tanaponudom.
the class NetworkConnectionManager method pushImage.
public void pushImage(final OnNetworkCallbackListener listener, MultipartBody.Part img, int user_id, String app_name, String app_detail, int dep_id) {
final Retrofit retrofit = new Retrofit.Builder().baseUrl(Fragment_login.BASE_URL).addConverterFactory(GsonConverterFactory.create()).build();
APISERVER git = retrofit.create(APISERVER.class);
Call call = git.updateImageProfile(img, user_id, app_name, app_detail, dep_id);
call.enqueue(new Callback<ResPOJO>() {
@Override
public void onResponse(Call<ResPOJO> call, Response<ResPOJO> response) {
ResPOJO res = response.body();
//
if (res == null) {
// 404 or the response cannot be converted to User.
ResponseBody responseBody = response.errorBody();
if (responseBody != null) {
listener.onBodyError(responseBody);
} else {
listener.onBodyErrorIsNull();
}
} else {
// 200
listener.onResponse(response.body(), retrofit);
Log.e("ResNet", "" + res.getUrl());
}
}
@Override
public void onFailure(Call<ResPOJO> call, Throwable t) {
listener.onFailure(t);
// Log.e("NWMG",t.getMessage());
}
});
}
Aggregations