Search in sources :

Example 81 with Call

use of zipkin2.Call 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 82 with Call

use of zipkin2.Call in project DVECTN by tanaponudom.

the class NetworkConnectionManager method callServer_dd_p2.

// /////////////////////////////////////////////////////////////////////////////////////////////////
public void callServer_dd_p2(final OnNetworkCallback_DD_P2 listener, int member_id, int ex22, int ex23, int ex24, int ex25, int ex26, int ex27, int ex28, int ex29) {
    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.getDataDDP2(member_id, ex22, ex23, ex24, ex25, ex26, ex27, ex28, ex29);
    call.enqueue(new Callback<POJO_DD_P2>() {

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

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

Example 83 with Call

use of zipkin2.Call 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)

Example 84 with Call

use of zipkin2.Call 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)

Example 85 with Call

use of zipkin2.Call in project DVECTN by tanaponudom.

the class NetworkConnectionManager method callSrever_trainer.

// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void callSrever_trainer(final OnNetworkCallback_trainer listener) {
    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_trainer();
    call.enqueue(new Callback<List<POJO_trainer>>() {

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

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

Aggregations

Call (okhttp3.Call)409 Response (okhttp3.Response)309 Request (okhttp3.Request)282 IOException (java.io.IOException)232 Call (retrofit2.Call)134 Callback (okhttp3.Callback)133 OkHttpClient (okhttp3.OkHttpClient)98 Test (org.junit.Test)88 ResponseBody (okhttp3.ResponseBody)76 RequestBody (okhttp3.RequestBody)58 Retrofit (retrofit2.Retrofit)48 Gson (com.google.gson.Gson)47 Response (retrofit2.Response)47 File (java.io.File)44 Headers (okhttp3.Headers)41 Callback (retrofit2.Callback)41 GsonBuilder (com.google.gson.GsonBuilder)40 JSONObject (org.json.JSONObject)39 MockResponse (okhttp3.mockwebserver.MockResponse)38 List (java.util.List)35