protected void onPostExecute(String result) {

      if (result != null && result.equalsIgnoreCase("true")) {
        Log.e("##Error!!!!", "Stop Exists");
        RoutesUtils.displayDialog(context, "Status", "Error Adding New Bus Stop to Route :(");
        return;
      }
      Log.d("####Update Route response received=", result);
      RoutesUtils.displayDialog(context, "Status", "Success adding bus stop to route :)");
      AppServices.sendNotificationToAll(
          context,
          "A new bus stop "
              + etStopName.getText().toString()
              + "has been added to route "
              + etName.getText().toString()
              + " in "
              + etCity.getText().toString()
              + ", "
              + etCountry.getText().toString());
      //                new MainActivity.GetAllRoutes().execute();
      RoutesUtils.allRoutesArray.clear();

      String urls[] = new String[2];
      urls[0] =
          "http://sujoyghosal-test.apigee.net/busroutenocache/creategroup?group="
              + etName.getText().toString().trim().toUpperCase().replace(" ", "-")
              + "-"
              + etStopName.getText().toString().trim().toUpperCase().replace(" ", "-");
      new CallCreateGroupAPI().execute(urls);
    }
 public void sendCreateRouteRequest(View v) {
   if (!validateInputs()) {
     RoutesUtils.displayDialog(context, "Input Issues", validateError);
     return;
   }
   geoCodeBusStopAddress();
 }
    protected void onPostExecute(String result) {
      if (result == null) {
        Log.e("##Error!!!!", "Could not create route.");
        RoutesUtils.displayDialog(context, "Create Route Status: ", "Failed to complete  request.");
        return;
      } else if (result.trim().equalsIgnoreCase("true")) {
        Log.e("##Error!!!!", "Could not create route. Response = true.");
        RoutesUtils.displayDialog(
            context,
            "Create Route Status: ",
            "Failed to complete  request. Route Exists With Same Name, need to call Update.");
        return;
      }
      Log.d("####Create Route response received=", result);
      tvResp.setText("Create Route Status:" + result);
      RoutesUtils.displayDialog(
          context, "Create Route Status", "You have successfully created route/stops.");
      AppServices.sendNotificationToAll(
          context,
          "The bus route named '"
              + etName.getText().toString()
              + "'  has been created/updated in "
              + etCity.getText().toString()
              + ", "
              + etCountry.getText().toString());
      /*            try {
          JSONObject j = new JSONObject(result);
          if(j!=null && j.has("_data")){
              JSONObject jd = j.getJSONObject("_data");
              if(jd!=null && jd.has("uuid"))

          }
      } catch (JSONException e) {
          e.printStackTrace();
      }*/

      String urls[] = new String[2];
      urls[0] =
          "http://sujoyghosal-test.apigee.net/busroutenocache/creategroup?group="
              + etName.getText().toString().trim().toUpperCase().replace(" ", "-")
              + "-"
              + etStopName.getText().toString().trim().toUpperCase().replace(" ", "-");
      new CallCreateGroupAPI().execute(urls);
      //                new MainActivity.GetAllRoutes().execute("");
      RoutesUtils.allRoutesArray.clear();
    }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.create_route);
    RoutesUtils.loadDeviceLocation(this);
    etName = (EditText) findViewById(R.id.editTextName);
    etStopName = (EditText) findViewById(R.id.editTextStopName);
    etStreet = (EditText) findViewById(R.id.editTextStreet);
    etCity = (EditText) findViewById(R.id.editTextCity);
    etState = (EditText) findViewById(R.id.editTextState);
    etCountry = (EditText) findViewById(R.id.editTextCountry);
    etPC = (EditText) findViewById(R.id.editTextPC);
    etDesc = (EditText) findViewById(R.id.editTextDesc);
    etAddress2 = (EditText) findViewById(R.id.editTextAddress2);

    tvResp = (TextView) findViewById(R.id.textViewResp);
  }
  private void createOrUpdateRoute() {
    RouteObject currRoute = null;
    for (int i = 0; i < RoutesUtils.allRoutesArray.size(); i++) {
      RouteObject r = RoutesUtils.allRoutesArray.get(i);
      if (r.getRouteName().equalsIgnoreCase(etName.getText().toString())) {
        currRoute = r;
        break;
      }
    }
    if (currRoute != null) { // route exists
      Log.d("##Curr Route Found:", currRoute.getRouteName());
      for (int i = 0; i < currRoute.getBusStopsArray().size(); i++) {
        RouteListActivity.RouteStopsObject rs = currRoute.getBusStopsArray().get(i);
        Log.d(
            "rs.getStopName,etStopName.getText()",
            rs.getStopName() + "=" + etStopName.getText().toString());
        if (rs.getStopName().trim().equalsIgnoreCase(etStopName.getText().toString().trim())) {
          Log.d("##Received request for Stop:", "Route and Stop name are same. Returning..");
          RoutesUtils.displayDialog(
              context, "Status", "This stopname already exists on this route");
          return;
        }
      }
      // To do - new stop on existing route - update route
      Log.d(
          "##Calling Route Update:",
          currRoute.getRouteName() + "-" + etStopName.getText().toString());
      RouteListActivity.RouteStopsObject o = new RouteListActivity.RouteStopsObject();
      o.setStopName(etStopName.getText().toString());
      o.setCity(etCity.getText().toString());
      o.setStreet(etStreet.getText().toString());
      o.setAddress2(etAddress2.getText().toString());
      o.setState(etState.getText().toString());
      o.setCountry(etCountry.getText().toString());
      o.setPC(etPC.getText().toString());
      o.setCoordinates(new RoutesUtils.Coordinates(shopLatitude, shopLongitude, ""));
      currRoute.busStopsArray.add(o);
      Log.d("##Curr Object After adding New Stop:", currRoute.toString());
      JSONArray ja = new JSONArray();
      JSONObject mainObj = new JSONObject();
      try {
        for (int i = 0; i < currRoute.busStopsArray.size(); i++) {
          JSONObject jo = new JSONObject();
          jo.put("route_name", currRoute.getRouteName());
          jo.put("description", currRoute.getRouteDesc());
          jo.put("stop_name", currRoute.busStopsArray.get(i).getStopName());
          jo.put("street", currRoute.busStopsArray.get(i).getStreet());
          jo.put("address_line2", currRoute.busStopsArray.get(i).getAddress2());
          jo.put("city", currRoute.busStopsArray.get(i).getCity());
          jo.put("state", currRoute.busStopsArray.get(i).getState());
          jo.put("postal_code", currRoute.busStopsArray.get(i).getPC());
          jo.put("country", currRoute.busStopsArray.get(i).getCountry());
          JSONObject locationOb = new JSONObject();
          locationOb.put("latitude", currRoute.busStopsArray.get(i).getCoordinates().getLatitude());
          locationOb.put(
              "longitude", currRoute.busStopsArray.get(i).getCoordinates().getLongitude());
          jo.put("location", locationOb);
          ja.put(jo);
        }
        mainObj.put("bus_stops", ja);
      } catch (JSONException e) {
        e.printStackTrace();
        Log.e("##Error!!!!", "Could not create routes object for update.");
        RoutesUtils.displayDialog(context, "Status: ", "Failed to add new bus stop.");
        return;
      }
      String urls[] = new String[2];
      String base = "http://sujoyghosal-test.apigee.net/busroutenocache/updateroute?";
      base += "&uuid=" + currRoute.getUUID() + "&bus_stops=" + Uri.encode(mainObj.toString());
      urls[0] = base;
      new CallUpdateRouteAPI().execute(urls);
    } else {
      Log.d("##Curr Route is null", "");
      String urls[] = new String[2];
      String base = "http://sujoyghosal-test.apigee.net/busroutenocache/createroute?";

      urls[0] =
          base
              + "routename="
              + Uri.encode(etName.getText().toString())
              + "&street="
              + Uri.encode(etStreet.getText().toString())
              + "&city="
              + Uri.encode(etCity.getText().toString())
              + "&address_line2="
              + Uri.encode(etAddress2.getText().toString())
              + "&state="
              + Uri.encode(etState.getText().toString())
              + "&postalcode="
              + Uri.encode(etPC.getText().toString())
              + "&country="
              + Uri.encode(etCountry.getText().toString())
              + "&stopname="
              + Uri.encode(etStopName.getText().toString())
              + "&latitude="
              + shopLatitude
              + "&longitude="
              + shopLongitude
              + "&description="
              + Uri.encode(etDesc.getText().toString());
      new CallCreateRouteAPI().execute(urls);
    }
  }