I am new in android. I have bought one android application template from codecanyon. This app was using OKHTTP and JSON for get and send data. I have hire one freelancer for implement Retrofit+GSON for networking purpose because I have read that its give Good Performance. He have changed and used response like below
public void onResponse(retrofit2.Call<JsonObject> call, retrofit2.Response<JsonObject> response) {
try {
final String myResponse = response.body().toString();
Log.e("CheckDevice", "" + myResponse);
JSONObject pJSONResponse = new JSONObject(myResponse);
if (pJSONResponse.getInt("code") == 1) {
NumberData.getInstance().mNews = pJSONResponse.getString("news");
Log.e("News", NumberData.getInstance().mNews);
SharedPreferences.Editor editor = getSharedPreferences("setting", MODE_PRIVATE).edit();
editor.putInt("membership", pJSONResponse.getInt("membership"));
editor.apply();
} else {
if (!SplashActivity.this.isFinishing()) {
AlertManager.createSingleCallbackAlert(mActivity, "Error", "Server Problem", false, "Retry", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
checkDevice(membership);
}
});
}
}
} catch (Exception e) {
if (!SplashActivity.this.isFinishing()) {
AlertManager.createSingleCallbackAlert(mActivity, "Error Occurred", "Error while communicating with server", false, "Retry", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
checkDevice(membership);
}
});
Log.e("Error", "" + e.toString());
}
}
}
I have told him to implement retrofit with proper way. I have marked that he have not used POJO and Instead used JsonObject directly in it. Can I know there any special benefit of using POJO or its OK to continue with above solution with JsonObject?
Thanks