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);
    }
Example #2
0
  // ---------------------------------------------------------------------------------------------
  @Override // Main method that executes when the activity starts. -------------------------------
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
    loggedInUserID = sharedPreferences.getInt("user_id", 0);
    activityTag = getString(R.string.activ_main_tag);
    AppServices.loggingAction(
        loggedInUserID, activityTag, getString(R.string.act_create_activ_tag), 0);
  }
Example #3
0
 // ---------------------------------------------------------------------------------------------
 // Method for checking if the user is connected on the internet. -------------------------------
 public static boolean isOnline(Context contextFrom) {
   ConnectivityManager connectivityManager =
       (ConnectivityManager) contextFrom.getSystemService(Context.CONNECTIVITY_SERVICE);
   NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo();
   if (netInfo != null && netInfo.isConnectedOrConnecting()) {
     return true;
   } else {
     AppServices.displayToast(contextFrom, "Κανένα διαθέσιμο δίκτυο");
     return false;
   }
 }
Example #4
0
  // ---------------------------------------------------------------------------------------------
  @Override // Main method that executes when the activity starts. -------------------------------
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_vet_first);

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(VetFirstActivity.this);
    loggedInUserID = sharedPreferences.getInt("user_id", 0);
    activityTag = getString(R.string.activ_vet_fir_tag);
    AppServices.loggingAction(
        loggedInUserID, activityTag, getString(R.string.act_create_activ_tag), 0);

    markerOptionsList = new ArrayList<>();
    if (ConnectionManager.isOnline(this)) {
      populateVetList();
    }
  }
    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();
    }
Example #6
0
  // ---------------------------------------------------------------------------------------------
  // Method that draws the route between two locations on the map. -------------------------------
  private void drawRoute(List<List<HashMap<String, String>>> routes) {
    ArrayList<LatLng> points;
    PolylineOptions polylineOptions = null;

    if (routes == null) {
      AppServices.displayToast(
          VetFirstActivity.this, "Προέκυψε κάποιο σφάλμα κατά τον προσδιορισμό της διαδρομής");
    } else {
      for (int i = 0; i < routes.size(); i++) {
        points = new ArrayList<>();
        polylineOptions = new PolylineOptions();
        List<HashMap<String, String>> path = routes.get(i);

        for (int j = 0; j < path.size(); j++) {
          HashMap<String, String> point = path.get(j);

          if (j == 0) {
            distance = point.get("distance");
            continue;
          } else if (j == 1) {
            duration = point.get("duration");
            continue;
          }

          double lat = Double.parseDouble(point.get("lat"));
          double lng = Double.parseDouble(point.get("lng"));
          LatLng position = new LatLng(lat, lng);
          points.add(position);
        }

        polylineOptions.addAll(points);
        polylineOptions.width(4);
        polylineOptions.color(Color.rgb(48, 48, 48));
      }

      Log.d(
          "VetFirstActivity",
          "distance (" + distance + ") and duration (" + duration + ") are set");
      vetMap.addPolyline(polylineOptions);
      updateDistanceAndDurationInfo(distance, duration);
    }
  }
Example #7
0
  // ---------------------------------------------------------------------------------------------
  @Override // Method that handles the different options of the menu. ----------------------------
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_login) {
      if (ConnectionManager.isOnline(this)) {
        Intent loginIntent = new Intent(this, LoginActivity.class);
        startActivity(loginIntent);
      }
    } else if (id == R.id.action_logout) {
      SharedPreferences sharedPreferences =
          PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
      SharedPreferences.Editor editor = sharedPreferences.edit();
      Integer loggedInUserID = sharedPreferences.getInt("user_id", 0);
      Integer checkInLocationID = sharedPreferences.getInt("check_in_location_id", 0);
      if (checkInLocationID != 0) {
        ConnectionManager.getCheckOutURL(loggedInUserID, checkInLocationID);
      }
      editor.clear();
      editor.apply();
      AppServices.displayToast(this, "Επιτυχής αποσύνδεση!");
    } else if (id == R.id.action_google_play_licence) {
      if (ConnectionManager.isOnline(this)) {
        Intent gpsLicenceIntent = new Intent(this, GooglePlayLicenceActivity.class);
        startActivity(gpsLicenceIntent);
      }
    } else if (id == R.id.action_app_licence) {
      Intent appLicenceIntent = new Intent(this, AppLicenceActivity.class);
      startActivity(appLicenceIntent);
    } else if (id == R.id.action_privacy_policy) {
      Intent privacyPolicyIntent = new Intent(this, PrivacyPolicyActivity.class);
      startActivity(privacyPolicyIntent);
    } else if (id == R.id.action_about) {
      Intent aboutIntent = new Intent(this, AboutActivity.class);
      startActivity(aboutIntent);
    }

    return true;
  }
Example #8
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   AppServices.loggingAction(
       loggedInUserID, activityTag, getString(R.string.act_stop_activ_tag), 0);
 }
Example #9
0
  // ---------------------------------------------------------------------------------------------
  // Method for finding current location of the user. --------------------------------------------
  private boolean specifyCurrentLocation() {
    vetMap.setMyLocationEnabled(true);

    Log.d("VetFirstActivity", "defining current location...");
    final String locationProvider = LocationManager.NETWORK_PROVIDER;
    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    LocationListener locationListener =
        new LocationListener() {
          @Override
          public void onLocationChanged(Location location) {
            currentLocationLat = location.getLatitude();
            currentLocationLng = location.getLongitude();
            Log.d(
                "VetFirstActivity",
                "onLocationChanged just set current location ("
                    + currentLocationLat
                    + ", "
                    + currentLocationLng
                    + ")");
          }

          @Override
          public void onStatusChanged(String provider, int status, Bundle extras) {
            Log.d("VetFirstActivity", "onStatusChanged");
          }

          @Override
          public void onProviderEnabled(String provider) {
            LocationManager tempLocationManager =
                (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            Location tempMyLocation = tempLocationManager.getLastKnownLocation(locationProvider);
            currentLocationLat = tempMyLocation.getLatitude();
            currentLocationLng = tempMyLocation.getLongitude();
            Log.d(
                "VetFirstActivity",
                "onProviderEnabled just set current location ("
                    + currentLocationLat
                    + ", "
                    + currentLocationLng
                    + ")");
          }

          @Override
          public void onProviderDisabled(String provider) {
            Log.d("VetFirstActivity", "onProviderDisabled");
            AppServices.displayToast(
                VetFirstActivity.this,
                "Η λειτουργία εντοπισμού της τοποθεσίας σας δεν είναι ενεργοποιημένη");
          }
        };

    locationManager.requestLocationUpdates(locationProvider, 0, 0, locationListener);

    if ((currentLocationLat == null) && (currentLocationLng == null)) {
      Location myLocation = locationManager.getLastKnownLocation(locationProvider);
      if (myLocation != null) {
        currentLocationLat = myLocation.getLatitude();
        currentLocationLng = myLocation.getLongitude();
        Log.d(
            "VetFirstActivity",
            "myLocation (" + currentLocationLat + ", " + currentLocationLng + ")");
      }
    }

    if ((currentLocationLat == null) && (currentLocationLng == null)) {
      AppServices.displayToast(VetFirstActivity.this, "Αδυναμία προσδιορισμού της τοποθεσίας σας");
      return false;
    } else {
      currentLocationLatLng = new LatLng(currentLocationLat, currentLocationLng);
      vetMap.addMarker(
          new MarkerOptions()
              .position(currentLocationLatLng)
              .title("Βρίσκεστε εδώ")
              .icon(currentLocationIcon));
      Log.d("VetFirstActivity", "marker of current location is set on map");
      // Stop listening for updates of the current location.
      locationManager.removeUpdates(locationListener);
      return true;
    }
  }