Search in sources :

Example 1 with POJO_AF_teacher

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

the class NetworkConnectionManager method callSrever_AF_teacher.

// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void callSrever_AF_teacher(final OnNetworkCallback_AF_teacher listener, String member_id) {
    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.getDataAF_teacher_company(member_id);
    call.enqueue(new Callback<List<POJO_AF_teacher>>() {

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

        @Override
        public void onFailure(Call<List<POJO_AF_teacher>> 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_AF_teacher(ctn.example.user.dvectn.POJO.POJO_AF_teacher) List(java.util.List)

Example 2 with POJO_AF_teacher

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

the class NetworkConnectionManager method callSrever_suppervision.

// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void callSrever_suppervision(final OnNetworkCallback_AF_teacher listener, String member_id, int suppervision) {
    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_dawae_now(member_id, suppervision);
    call.enqueue(new Callback<List<POJO_AF_teacher>>() {

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

        @Override
        public void onFailure(Call<List<POJO_AF_teacher>> 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_AF_teacher(ctn.example.user.dvectn.POJO.POJO_AF_teacher) List(java.util.List)

Aggregations

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