title: Why Android Circle Progress Dialog Getting Freezes when Bunch of Data Syncing from Server to Local DB Using Retrofit
body: <p>1.Iam fetching <strong>Bulk of Data from Server</strong> and Inserting in the Local Database While Login in android.</p>
  
  <p>2.For Syncing Purpose i have Used <strong>Retrofit Library</strong>, Syncing and Inserting Working Fine.</p>
  
  <p>My Problem: <strong>While Syncing Bunch of Data from server Using Retrofit</strong> ,<strong>Circle  Progress Dialog Getting Freeze</strong>.</p>
  
  <p>Help me how to Fix this Issue.</p>
  
  <p><strong>EDIT:1</strong> </p>
  
  <p>Called Retrofit method inside Async task ,Still <strong>Circle ProgressDialog Getting Freeze</strong> </p>
  
  <p>//Calling the Async Task</p>
  
  <pre><code>Asynctask_Getdata task=new Asynctask_Getdata(TokenType_StringValue,Access_Token_StringValue, ID_StringValue);
     task.execute();
  </code></pre>
  
  <p>//AsyncTask MEthod</p>
  
  <pre><code>public class Asynctask_Getdata extends AsyncTask&lt;String,Void,Void&gt;
      {
  
          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;
          }
  
          @Override
          protected void onPreExecute()
          {
              super.onPreExecute();
  
              if (!pDialog.isShowing())
              {
                  pDialog.setIndeterminate(true);
                  pDialog.setCanceledOnTouchOutside(false);
                  pDialog.setMessage("Please Wait Getting Data...");
                  pDialog.show();
              }
          }
  
          @Override
          protected void onPostExecute(Void aVoid)
          {
  
              super.onPostExecute(aVoid);
          }
  
          @Override
          protected Void doInBackground(String... params)
          {
              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&lt;CommonResponse&gt;() {
                              @Override
                              public void success(CommonResponse commonResponse, Response response) {
  
                                  Timber.d("sendOtpAPICall%s", commonResponse.getStatusCode());
  
                                  switch (commonResponse.getStatusCode()) {
                                      case 200:
  
  
                                          try {
  
  
                                              JSONArray jsonarray = null;
                                              try {
                                                  jsonarray = new JSONArray(commonResponse.getRouteMaster());
  
                                                  if (!commonResponse.getRouteMaster().equals("[]")) 
                                                   {
                                                      for (int i = 0; i &lt; jsonarray.length(); i++) 
                                                        {
                                                          JSONObject jsonobject = jsonarray.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;
  
                                  }
                              }
  
                              @Override
                              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 server");
                                      }
  
  
                                  } catch (Exception e) {
                                      e.printStackTrace();
                                      Toast.makeText(LoginPage.this, R.string.something_wrong, Toast.LENGTH_LONG).show();
                                  }
  
  
                              }
  
                          });
  
              }
  </code></pre>