Search in sources :

Example 1 with POJO_PJ_P2

use of com.example.user.dvectn.POJO.POJO_PJ_P2 in project DVECTN by tanaponudom.

the class NetworkConnectionManager method callServer_pj_p2.

// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void callServer_pj_p2(final OnNetworkCallback_PJ_P2 listener, int member_id, int ex21, int ex22, int ex23, int ex24, int ex25, int ex26, int ex27, int ex28) {
    Gson gson = new GsonBuilder().setLenient().create();
    final Retrofit retrofit = new Retrofit.Builder().baseUrl(Fragment_login.BASE_URL).addConverterFactory(GsonConverterFactory.create(gson)).build();
    APISERVER callapi = retrofit.create(APISERVER.class);
    Call call = callapi.getDataPJP2(member_id, ex21, ex22, ex23, ex24, ex25, ex26, ex27, ex28);
    call.enqueue(new Callback<POJO_PJ_P2>() {

        @Override
        public void onResponse(Call<POJO_PJ_P2> call, Response<POJO_PJ_P2> response) {
            try {
                POJO_PJ_P2 assessmentstu2 = (POJO_PJ_P2) response.body();
                if (response.code() != 200) {
                    // Log.e("Network connected","Response code = "+response.code());
                    ResponseBody responseBody = response.errorBody();
                    if (responseBody != null) {
                        listener.onBodyError(responseBody);
                    } else if (responseBody == null) {
                        listener.onBodyErrorIsNull();
                    }
                // Toast.makeText(, ""+loginRes.getAccesstoken(), Toast.LENGTH_SHORT).show();
                // Log.e("Network connected","Response code = "+loginRes.getAccesstoken());
                } else {
                    listener.onResponse(assessmentstu2);
                }
            } catch (Exception e) {
            // Log.e("Network connect error",e.getMessage());
            }
        }

        @Override
        public void onFailure(Call<POJO_PJ_P2> call, Throwable t) {
            Log.e("NT", t.getMessage());
            try {
                listener.onFailure(t);
            } catch (Exception e) {
                listener.onFailure(t);
            // Log.e("Network connectLogin",t.getMessage());
            }
        }
    });
}
Also used : Call(retrofit2.Call) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) ResponseBody(okhttp3.ResponseBody) Retrofit(retrofit2.Retrofit) POJO_PJ_P2(com.example.user.dvectn.POJO.POJO_PJ_P2)

Aggregations

POJO_PJ_P2 (com.example.user.dvectn.POJO.POJO_PJ_P2)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 ResponseBody (okhttp3.ResponseBody)1 Call (retrofit2.Call)1 Retrofit (retrofit2.Retrofit)1