Пример #1
0
 // ---------------------------------------------------------------------------------------------
 // Method for getting the route from an initial location to a target location. -----------------
 private void getRoute(LatLng initLocationLatLng, LatLng destLocationLatLng) {
   GetRouteTask getRouteTask = new GetRouteTask();
   Log.d(
       "VetFirstActivity",
       ConnectionManager.getDirectionsURL(initLocationLatLng, destLocationLatLng));
   getRouteTask.execute(
       ConnectionManager.getDirectionsURL(initLocationLatLng, destLocationLatLng));
   vetMap.moveCamera(CameraUpdateFactory.newLatLngZoom(destLocationLatLng, 14.0f));
 }
Пример #2
0
 // ---------------------------------------------------------------------------------------------
 // Method for updating the icons of the markers and plotting the new route. --------------------
 private void updateMarkersAndRoute(Marker marker) {
   Log.d("VetFirstActivity", ">> Marker clicked: " + marker.getTitle());
   vetMap.clear();
   int temp_i = 0;
   for (int i = 0; i < markerOptionsList.size(); i++) {
     if (marker.getTitle().equals(markerOptionsList.get(i).getTitle())) {
       temp_i = i;
       Log.d("VetFirstActivity", ">> Position in list:" + temp_i);
     }
   }
   for (int i = 0; i < markerOptionsList.size(); i++) {
     if ((i != nearestVetPosition) && (i != temp_i)) {
       vetMap.addMarker(markerOptionsList.get(i).icon(vetIcon).alpha(0.6f));
     } else if ((i != nearestVetPosition) && (i == temp_i)) {
       vetMap.addMarker(markerOptionsList.get(i).icon(vetIcon).alpha(1f));
     } else {
       vetMap.addMarker(markerOptionsList.get(i).icon(nearestVetIcon));
     }
   }
   vetMap.addMarker(
       new MarkerOptions()
           .position(currentLocationLatLng)
           .title("Βρίσκεστε εδώ")
           .icon(currentLocationIcon));
   GetRouteTask markerGetRouteTask = new GetRouteTask();
   markerGetRouteTask.execute(
       ConnectionManager.getDirectionsURL(currentLocationLatLng, vetLatLng));
   vetMap.animateCamera(CameraUpdateFactory.newLatLng(vetLatLng));
 }
Пример #3
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;
  }
Пример #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();
    }
  }
Пример #5
0
 // ---------------------------------------------------------------------------------------------
 // Method that handles the click on the location button and leads to the respective activity. --
 public void locationClickHandler(View view) {
   if (ConnectionManager.isOnline(this)) {
     Intent playLocationIntent = new Intent(this, PlayLocationActivity.class);
     startActivity(playLocationIntent);
   }
 }
Пример #6
0
 @Override
 protected String doInBackground(String... params) {
   return ConnectionManager.getData(params[0]);
 }
Пример #7
0
 // ---------------------------------------------------------------------------------------------
 // Method for getting vet data and creating the respective list. -------------------------------
 private void populateVetList() {
   GetVetsTask getVetsTask = new GetVetsTask();
   getVetsTask.execute(ConnectionManager.getVetsURL());
 }