Search in sources :

Example 76 with Call

use of zipkin2.Call in project DVECTN by tanaponudom.

the class NetworkConnectionManager method callServer_dd_p1.

// ///////////////////////////////////////////////////////////////////////////////////////////////
public void callServer_dd_p1(final OnNetworkCallback_DD_P1 listener, int member_id, int ex11, int ex12, int ex13, int ex14, int ex15) {
    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.getDataDDP1(member_id, ex11, ex12, ex13, ex14, ex15);
    call.enqueue(new Callback<POJO_DD_P1>() {

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

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

Example 77 with Call

use of zipkin2.Call in project DVECTN by tanaponudom.

the class NetworkConnectionManager method callServer_pj_p1.

// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void callServer_pj_p1(final OnNetworkCallback_PJ_P1 listener, int member_id, int ex11, int ex12) {
    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.getDataPJP1(member_id, ex11, ex12);
    call.enqueue(new Callback<POJO_PJ_P1>() {

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

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

Example 78 with Call

use of zipkin2.Call in project DVECTN by tanaponudom.

the class NetworkConnectionManager method callServer_pj_p5.

// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void callServer_pj_p5(final OnNetworkCallback_PJ_P5 listener, int member_id, int ex51, int ex52, int ex53, int ex54, int ex55, int ex56) {
    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.getDataPJP5(member_id, ex51, ex52, ex53, ex54, ex55, ex56);
    call.enqueue(new Callback<POJO_PJ_P5>() {

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

        @Override
        public void onFailure(Call<POJO_PJ_P5> 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_P5(ctn.example.user.dvectn.POJO.POJO_PJ_P5)

Example 79 with Call

use of zipkin2.Call in project DVECTN by tanaponudom.

the class NetworkConnectionManager method callServer_Checkdaily.

// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void callServer_Checkdaily(final OnNetworkCallback_Checkdaily_D1 listener, String name_std, int score) {
    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.getDatadaily(name_std, score);
    call.enqueue(new Callback<POJO_Checkdaily>() {

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

        @Override
        public void onFailure(Call<POJO_Checkdaily> 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_Checkdaily(ctn.example.user.dvectn.POJO.POJO_Checkdaily)

Example 80 with Call

use of zipkin2.Call in project DVECTN by tanaponudom.

the class NetworkConnectionManager method callServerLogin.

public void callServerLogin(final OnNetworkCallbackLoginListener listener, String username, String password) {
    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.loginHandle(username, password);
    call.enqueue(new Callback<POJO_login>() {

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

        @Override
        public void onFailure(Call<POJO_login> call, Throwable t) {
            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_login(ctn.example.user.dvectn.POJO.POJO_login)

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