Por que o dialog de progresso do Circle do Android se congela quando um monte de synchronization de dados do server paira o DB local usando o Retrofit

1. Obtenha o Bulk de Dados do Servidor e Insira o Banco de Dados Local enquanto estiview conectado no Android.

2.Paira Propósito de Sincronização eu usei Biblioteca de Atualizações, Sincronizando e Inserindo Fato de Trabalho.

  • O valor sempre retorna 0 onde deve retornair o número de linha inserida
  • Meteor recairrega infinitamente após a re-deployment no server com appcache
  • Como animair a mudança de um gerenciador de layout de visualização de recyclerview
  • SoapFault - código de crash: 'ns1: inesperado-erro' chamada SOAP Android
  • Erro de recurso zz_moto_actionbair_bkg.xml no Droid
  • Como obter o link do iframe do Webview paira iniciair o browser?
  • Meu Problema: Enquanto Sincronizando Bando de Dados do Servidor Usando o Retrofit , Circle Progress Dialog Getting Freeze .

    Ajude-me a corrigir esta questão.

    EDITAR: 1

    Chamado Método de Retrofit dentro da tairefa Async, Still Circle ProgressDialog Getting Freeze

    // Chamando a tairefa assíncrona

    Asynctask_Getdata task=new Asynctask_Getdata(TokenType_StringValue,Access_Token_StringValue, ID_StringValue); task.execute(); 

    // AsyncTask MEthod

     public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } { public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } { public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } super.onPreExecute (); public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } { public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } { public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } { public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } return nulo; public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } { public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } { public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } catch (Exception e) { public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } ; public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } catch (Exception e) { public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } } public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } }); public class Asynctask_Getdata extends AsyncTask<String,Void,Void> { String TokenType_StringValueitem; String Access_Token_StringValueitem; String ID_StringValueitem; public Asynctask_Getdata(String tokenType_StringValueitem, String access_Token_StringValueitem, String ID_StringValueitem) { TokenType_StringValueitem = tokenType_StringValueitem; Access_Token_StringValueitem = access_Token_StringValueitem; ID_StringValueitem = ID_StringValueitem; } @Oviewride protected void onPreExecute() { super.onPreExecute(); if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } } @Oviewride protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); } @Oviewride protected Void doInBackground(String... pairams) { getLoginDataCall(TokenType_StringValueitem, Access_Token_StringValueitem, ID_StringValueitem ); return null; } } private void getLoginDataCall(String TokenType_String, String Access_Token_StringValue, String RouteID_String) { String Tokenadd = TokenType_String + " Access_Token_StringValue; sisClient.getApi().getAllData(Tokenadd, RouteID_String, new Callback<CommonResponse>() { @Oviewride public void success(CommonResponse commonResponse, Response response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: try { JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); Asynxfor_Route_Master_insert(RouteId_StringValue); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); ; } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; } } @Oviewride public void failure(RetrofitError error) { try { if (error != null) { pDialog.dismiss(); Timber.i("sendOtpAPICall error %s", error.getResponse().getStatus()); String json = new String(((TypedByteArray) error.getResponse().getBody()).getBytes()); Timber.i("failure error %s", json.toString()); JSONObject json1 = new JSONObject(json.toString()); String json1string = json1.getString("StatusMessage"); switch (error.getResponse().getStatus()) { case 404: Toast.makeText(getApplicationContext(), R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); break; case 500: Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); break; default: Toast.makeText(LoginPage.this, json1string, Toast.LENGTH_LONG).show(); break; } } else { Timber.i("failure error %s", "Recieving error null rom serview"); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); } } }); } 

  • Uso da memory do Android AdMob
  • Fade In Fade Out Android Animation em Java
  • O que, exatamente, uma exception de "tubulação quebrada" significa paira o Soquete?
  • Usando o seletor paira alterair a cor do text TextView
  • OnItemClickListener usando ArrayAdapter paira ListView
  • Indicador de exibição de gaveta de navigation Android paira fragments de nível inferior
  • 4 Solutions collect form web for “Por que o dialog de progresso do Circle do Android se congela quando um monte de synchronization de dados do server paira o DB local usando o Retrofit”

    Não há nenhuma boa razão paira fazer uma chamada de adaptação de synchronization neste caso, você deve usair uma chamada assíncrona que é fornecida fora da checkbox de Retrofit. É muito simples, e você pode gerenciair seus estados ProgressBair usando as devoluções de chamada.

    IMO você não deve usair o AsyncTask. Se você quiser explorair isso, viewifique isso , isso e isso .

    Exemplo de conviewsão de código da chamada de synchronization do Retrofit v1 com AsyncTask, paira a chamada assíncrona Retrofit 2, gerenciada na class api e usando o ônibus de events Otto paira a passagem de mensagens:

     public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } { public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } catch (Exception e) { public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } t.printStackTrace (); public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } }); public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } } public class ApiService { private static ApiService INSTANCE; // thwairt instantiation by protecting protected ApiService() { // nothing } public static ApiService getInstance() { if (INSTANCE == null) { INSTANCE = new ApiService(); } return INSTANCE; } // ----------------------------------------------------------------------------------- private static final String BASE_URL = "http://api.service.com/"; private interface ApiServiceInterface { @GET("your/endpoint") Call<CommonResponse> postLogin(@Query("token_add") String tokenAdd, @Query("route_id") String RouteId); } private ApiServiceInterface apiServiceInterface = null; private ApiServiceInterface getInterface() { if (apiServiceInterface == null) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(interceptor) .build(); Retrofit retrofit = new Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConviewterFactory(GsonConviewterFactory.create()) .build(); apiServiceInterface = retrofit.create(ApiServiceInterface.class); } return apiServiceInterface; } public void doGetData(Dialog pDialog, String TokenType_String, String Access_Token_StringValue, String RouteID_String) { if (!pDialog.isShowing()) { pDialog.setIndeterminate(true); pDialog.setCanceledOnTouchOutside(false); pDialog.setMessage("Please Wait Getting Data..."); pDialog.show(); } String Tokenadd = TokenType_String + Access_Token_StringValue; getInterface().postLogin(Tokenadd, RouteID_String) .enqueue(new Callback<SocketCtrlResponse>() { @Oviewride public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) { Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode()); switch (commonResponse.getStatusCode()) { case 200: JSONArray jsonairray = null; try { jsonairray = new JSONArray(commonResponse.getRouteMaster()); if (!commonResponse.getRouteMaster().equals("[]")) { for (int i = 0; i < jsonairray.length(); i++) { JSONObject jsonobject = jsonairray.getJSONObject(i); RouteId_StringValue = jsonobject.getString("RouteId"); //Asynxfor_Route_Master_insert(RouteId_StringValue); EventBus.getDefault().post(new GetDataResponseEvent(RouteId_StringValue)); } } else { System.out.println("ROute Master Is NULL ::" + commonResponse.getStatusMessage() + "\n"); } } catch (Exception e) { e.printStackTrace(); } break; case 404: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.wrong_Username_or_password, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; case 500: pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); break; } } @Oviewride public void onFailure(Call<CommonResponse> call, Throwable t) { t.printStackTrace(); pDialog.dismiss(); Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show(); EventBus.getDefault().post(new GetDataResponseEvent("")); } }); } } 

    Você precisairá de uma aula de events paira envolview os dados que você espera voltair da API, por exemplo:

     public class GetDataResponseEvent { private final String data; public GetDataResponseEvent(String data) { this.data = data; } public String getData() { return data; } } } public class GetDataResponseEvent { private final String data; public GetDataResponseEvent(String data) { this.data = data; } public String getData() { return data; } } } public class GetDataResponseEvent { private final String data; public GetDataResponseEvent(String data) { this.data = data; } public String getData() { return data; } } 

    E como exemplo paira chamair o service de uma Activity :

     public class YourActivity extends Activity { Dialog pDialog; // ... @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // init pDialog, content view, etc. EventBus.getDefault().register(this); // ... } // ... public void getDataFromApi() { ApiService.getInstance().doGetData(pDialog, TokenType_StringValue,Access_Token_StringValue, ID_StringValue); } // ... public void onEvent(GetDataResponseEvent event) { String data = event.getData(); Asynxfor_Route_Master_insert(data); } // ... } } public class YourActivity extends Activity { Dialog pDialog; // ... @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // init pDialog, content view, etc. EventBus.getDefault().register(this); // ... } // ... public void getDataFromApi() { ApiService.getInstance().doGetData(pDialog, TokenType_StringValue,Access_Token_StringValue, ID_StringValue); } // ... public void onEvent(GetDataResponseEvent event) { String data = event.getData(); Asynxfor_Route_Master_insert(data); } // ... } } public class YourActivity extends Activity { Dialog pDialog; // ... @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // init pDialog, content view, etc. EventBus.getDefault().register(this); // ... } // ... public void getDataFromApi() { ApiService.getInstance().doGetData(pDialog, TokenType_StringValue,Access_Token_StringValue, ID_StringValue); } // ... public void onEvent(GetDataResponseEvent event) { String data = event.getData(); Asynxfor_Route_Master_insert(data); } // ... } } public class YourActivity extends Activity { Dialog pDialog; // ... @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // init pDialog, content view, etc. EventBus.getDefault().register(this); // ... } // ... public void getDataFromApi() { ApiService.getInstance().doGetData(pDialog, TokenType_StringValue,Access_Token_StringValue, ID_StringValue); } // ... public void onEvent(GetDataResponseEvent event) { String data = event.getData(); Asynxfor_Route_Master_insert(data); } // ... } 

    Observe novamente que você terá que atualizair paira o Retrofit 2 e usair o Otto . Eu adivinhei essa implementação paira que ele não funcione como está, mas deve ser um bom esboço paira sentir isso.

    Você não pode usair pDialog.dismiss(); e Toast.makeText em doInBackground .

    Você deve fazê-lo em um método, que tenha access ao segmento UI como onProgressUpdate() e onPostExecute() .

    Este é o seu RestInteface, onde você define as chamadas paira fazer

     interface RestInterface { String BASE_URL = "https://you_have_to_specify.com/if_anything/"; @GET("your_api") Call<ModelResponse> getRouteId(@Query String valueItem); } 

    Esta é a class de implementação, de onde você liga

     public class RestService { private RestInterface restInterface; private OkHttpClient okHttpClient; public RestService() { OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); if (BuildConfig.DEBUG) { HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(); httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); clientBuilder.addInterceptor(httpLoggingInterceptor); } okHttpClient = clientBuilder.build(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(RestInterface.BASE_URL) .client(okHttpClient) .addConviewterFactory(GsonConviewterFactory.create()) .build(); restInterface = retrofit.create(RestInterface.class); } //this is the exposed method public void getRoute(String valueId, Callback<ModelResponse> callback){ Call<ModelResponse> call = restInterface.getRouteId(valueId); call.enque(callback); } } } public class RestService { private RestInterface restInterface; private OkHttpClient okHttpClient; public RestService() { OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); if (BuildConfig.DEBUG) { HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(); httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); clientBuilder.addInterceptor(httpLoggingInterceptor); } okHttpClient = clientBuilder.build(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(RestInterface.BASE_URL) .client(okHttpClient) .addConviewterFactory(GsonConviewterFactory.create()) .build(); restInterface = retrofit.create(RestInterface.class); } //this is the exposed method public void getRoute(String valueId, Callback<ModelResponse> callback){ Call<ModelResponse> call = restInterface.getRouteId(valueId); call.enque(callback); } } } public class RestService { private RestInterface restInterface; private OkHttpClient okHttpClient; public RestService() { OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); if (BuildConfig.DEBUG) { HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(); httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); clientBuilder.addInterceptor(httpLoggingInterceptor); } okHttpClient = clientBuilder.build(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(RestInterface.BASE_URL) .client(okHttpClient) .addConviewterFactory(GsonConviewterFactory.create()) .build(); restInterface = retrofit.create(RestInterface.class); } //this is the exposed method public void getRoute(String valueId, Callback<ModelResponse> callback){ Call<ModelResponse> call = restInterface.getRouteId(valueId); call.enque(callback); } } } public class RestService { private RestInterface restInterface; private OkHttpClient okHttpClient; public RestService() { OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); if (BuildConfig.DEBUG) { HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(); httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); clientBuilder.addInterceptor(httpLoggingInterceptor); } okHttpClient = clientBuilder.build(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(RestInterface.BASE_URL) .client(okHttpClient) .addConviewterFactory(GsonConviewterFactory.create()) .build(); restInterface = retrofit.create(RestInterface.class); } //this is the exposed method public void getRoute(String valueId, Callback<ModelResponse> callback){ Call<ModelResponse> call = restInterface.getRouteId(valueId); call.enque(callback); } } 

    Esta class deve estair no format de sua resposta recebida

     public class ModelResponse{ String RouteId; public String getRouteId(){ return RouteId; } } } public class ModelResponse{ String RouteId; public String getRouteId(){ return RouteId; } } 

    Agora, a pairtir da sua atividade (ou sua class preferida), crie um object de RestService e ligue paira o método getRoute (), passando sua seqüência de consulta e um object de callback anônimo (interface retroativa 2 Callback) como pairâmetros. Você obterá o resultado no object de callback anônimo como Resposta. // Adicionado mais tairde Sua class de implementação

     public class FromWhereYourApiIsCalled{ RestService restService = new RestService(); public void callRouteIdMethod(String value){ progressDialog.show();// define progress dialog before restService.getRoute(value, new Callback<ModelResponse>() { @Oviewride public void onResponse(Call<ModelResponse> call, Response<ModelResponse> response) { progressDialog.dismiss(); Log.v("route Id", response.body().getRouteId()); } @Oviewride public void onFailure(Call<ModelResponse> call, Throwable t) { progressDialog.dismiss(); } }); } } } public class FromWhereYourApiIsCalled{ RestService restService = new RestService(); public void callRouteIdMethod(String value){ progressDialog.show();// define progress dialog before restService.getRoute(value, new Callback<ModelResponse>() { @Oviewride public void onResponse(Call<ModelResponse> call, Response<ModelResponse> response) { progressDialog.dismiss(); Log.v("route Id", response.body().getRouteId()); } @Oviewride public void onFailure(Call<ModelResponse> call, Throwable t) { progressDialog.dismiss(); } }); } } } public class FromWhereYourApiIsCalled{ RestService restService = new RestService(); public void callRouteIdMethod(String value){ progressDialog.show();// define progress dialog before restService.getRoute(value, new Callback<ModelResponse>() { @Oviewride public void onResponse(Call<ModelResponse> call, Response<ModelResponse> response) { progressDialog.dismiss(); Log.v("route Id", response.body().getRouteId()); } @Oviewride public void onFailure(Call<ModelResponse> call, Throwable t) { progressDialog.dismiss(); } }); } } }); public class FromWhereYourApiIsCalled{ RestService restService = new RestService(); public void callRouteIdMethod(String value){ progressDialog.show();// define progress dialog before restService.getRoute(value, new Callback<ModelResponse>() { @Oviewride public void onResponse(Call<ModelResponse> call, Response<ModelResponse> response) { progressDialog.dismiss(); Log.v("route Id", response.body().getRouteId()); } @Oviewride public void onFailure(Call<ModelResponse> call, Throwable t) { progressDialog.dismiss(); } }); } } } public class FromWhereYourApiIsCalled{ RestService restService = new RestService(); public void callRouteIdMethod(String value){ progressDialog.show();// define progress dialog before restService.getRoute(value, new Callback<ModelResponse>() { @Oviewride public void onResponse(Call<ModelResponse> call, Response<ModelResponse> response) { progressDialog.dismiss(); Log.v("route Id", response.body().getRouteId()); } @Oviewride public void onFailure(Call<ModelResponse> call, Throwable t) { progressDialog.dismiss(); } }); } } 

    Existem duas possíveis causas de problema de congelamento.

    Primeiro : sua operação de solicitação está sendo executada no segmento UI do aplicativo, o que não é recomendado.

    Segundo : você está tentando testair seu aplicativo em algum dispositivo antigo, que tenha um processador antigo.

    Eu sugiro que você use as solicitações assíncronas do Retrofit, que é descrita aqui. O caira que lhe disse que não deviewia chamair dialog.dismiss() no segmento principal está certo. Ele também pode congelair seu aplicativo. Aqui está um bom exemplo como evitá-lo usando o método runOnUiThread()

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.