Search in sources :

Example 1 with POJO_save_AG

use of ctn.example.user.dvectn.POJO.POJO_save_AG in project DVECTN by tanaponudom.

the class NetworkConnectionManager method callSrever_save_AG.

// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
public void callSrever_save_AG(final OnNetworkCallback_save_AG listener, int member_id, int check_dep) {
    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.get_save_ag(member_id, check_dep);
    call.enqueue(new Callback<List<POJO_save_AG>>() {

        @Override
        public void onResponse(Call<List<POJO_save_AG>> call, Response<List<POJO_save_AG>> response) {
            try {
                List<POJO_save_AG> get_confirm = (List<POJO_save_AG>) 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(get_confirm);
                }
            } catch (Exception e) {
            // Log.e("Network connect error",e.getMessage());
            }
        }

        @Override
        public void onFailure(Call<List<POJO_save_AG>> 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) POJO_save_AG(ctn.example.user.dvectn.POJO.POJO_save_AG) ResponseBody(okhttp3.ResponseBody) Retrofit(retrofit2.Retrofit) List(java.util.List)

Aggregations

Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 POJO_save_AG (ctn.example.user.dvectn.POJO.POJO_save_AG)1 List (java.util.List)1 ResponseBody (okhttp3.ResponseBody)1 Call (retrofit2.Call)1 Retrofit (retrofit2.Retrofit)1