@Override
  protected void onPostExecute(ArrayList<RouteChangesEntity> routeChangesList) {
    super.onPostExecute(routeChangesList);

    if (routeChangesList == null) {
      ActivityUtils.showNoInternetToast(context);
    } else if (routeChangesList.size() == 0) {
      Toast.makeText(
              context, context.getString(R.string.route_changes_list_empty_text), Toast.LENGTH_LONG)
          .show();
    } else {
      switch (loadType) {
        case INIT:
          Bundle bundle = new Bundle();
          bundle.putSerializable(RouteChanges.BUNDLE_ROUTE_CHANGES_NEWS_LIST, routeChangesList);

          Intent routeChangesIntent;
          if (globalContext.isPhoneDevice()) {
            routeChangesIntent = new Intent(context, RouteChanges.class);
          } else {
            routeChangesIntent = new Intent(context, RouteChangesDialog.class);
          }

          routeChangesIntent.putExtras(bundle);
          context.startActivity(routeChangesIntent);
          break;
        default:
          ((RouteChanges) context).refreshRouteChangesList(routeChangesList);
          break;
      }
    }

    dismissLoadingView();
  }
  public RetrieveRouteChanges(
      FragmentActivity context, ProgressDialog progressDialog, LoadTypeEnum loadType) {

    this.context = context;
    this.globalContext = (GlobalEntity) context.getApplicationContext();

    this.progressDialog = progressDialog;
    this.loadType = loadType;

    this.responseHandler = ActivityUtils.getUtfResponseHandler();
  }
  /** Create the loading view and lock the screen */
  private void createLoadingView() {
    ActivityUtils.lockScreenOrientation(context);

    if (loadType == LoadTypeEnum.INIT) {
      progressDialog.setIndeterminate(true);
      progressDialog.setCancelable(true);
      progressDialog.setOnCancelListener(
          new DialogInterface.OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
              cancel(true);
            }
          });
      progressDialog.show();
    }
  }
  /** Dismiss the loading view and unlock the screen */
  private void dismissLoadingView() {
    try {
      if (progressDialog != null) {
        progressDialog.dismiss();
      }
    } catch (Exception e) {
      /**
       * Fixing a strange error that is happening sometimes when the dialog is dismissed. I guess
       * sometimes activity gets finished before the dialog successfully dismisses.
       *
       * <p>java.lang.IllegalArgumentException: View not attached to window manager
       */
    }

    ActivityUtils.unlockScreenOrientation(context);
  }