use of garbagecollectors.com.unipool.models.GenLocation in project UniPool by divya21raj.
the class NewEntryDialog method getCurrentPlace.
public static void getCurrentPlace(Context context) {
final Place[] place = new Place[1];
final LatLng[] latLng = new LatLng[1];
@SuppressLint("MissingPermission") PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(likelyPlaces -> {
try {
PlaceLikelihood placeLikelihood = likelyPlaces.get(0);
place[0] = placeLikelihood.getPlace();
latLng[0] = place[0].getLatLng();
if (currentLocationView.getTag().equals("gct_source")) {
source = new GenLocation(place[0].getName().toString(), place[0].getAddress().toString(), latLng[0].latitude, latLng[0].longitude);
sourceSet = (place[0].getName() + ",\n" + place[0].getAddress() + "\n" + // check
place[0].getPhoneNumber());
findSource.setText(sourceSet);
} else if (currentLocationView.getTag().equals("gct_destination")) {
destination = new GenLocation(place[0].getName().toString(), place[0].getAddress().toString(), latLng[0].latitude, latLng[0].longitude);
destinationSet = (place[0].getName() + ",\n" + place[0].getAddress() + "\n" + // check
place[0].getPhoneNumber());
findDestination.setText(destinationSet);
}
likelyPlaces.release();
} catch (IllegalStateException ils) {
Toast.makeText(context, "Turn on 'Location' option on your phone to use this feature...", Toast.LENGTH_LONG).show();
findSource.setText("Source");
findDestination.setText("Destination");
}
});
}
use of garbagecollectors.com.unipool.models.GenLocation in project UniPool by divya21raj.
the class NewEntryDialog method predictSourceAndDestination.
private void predictSourceAndDestination() {
Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DAY_OF_WEEK);
if (day == Calendar.SATURDAY || day == Calendar.SUNDAY) {
findDestination.setText(R.string.uni_name);
destination = new GenLocation(Globals.uniInfo.get("name"), Globals.uniInfo.get("address"), Double.parseDouble(Globals.uniInfo.get("latitude")), Double.parseDouble(Globals.uniInfo.get("longitude")));
} else {
findSource.setText(R.string.uni_name);
source = new GenLocation(Globals.uniInfo.get("name"), Globals.uniInfo.get("address"), Double.parseDouble(Globals.uniInfo.get("latitude")), Double.parseDouble(Globals.uniInfo.get("longitude")));
}
}
use of garbagecollectors.com.unipool.models.GenLocation in project UniPool by divya21raj.
the class LoginActivity method dummyInitFinalCurrentUser.
private void dummyInitFinalCurrentUser(FirebaseUser user) {
GenLocation dummyGenLocation = new GenLocation("dummy", "dummy", 0d, 0d);
TripEntry dummyTripEntry = new TripEntry("dummy", "dummyId", "DummyUser", "12:00", "1/11/12", dummyGenLocation, dummyGenLocation, "dummyMessage", "", "", true);
HashMap<String, TripEntry> dummyUserEntries = new HashMap<>();
dummyUserEntries.put("dummy", dummyTripEntry);
HashMap<String, TripEntry> dummyRequestSent = new HashMap<>();
dummyRequestSent.put(dummyTripEntry.getEntry_id(), dummyTripEntry);
ArrayList<String> dummyUserIdList = new ArrayList<>();
dummyUserIdList.add("dummy");
HashMap<String, ArrayList<String>> dummyRequestReceived = new HashMap<>();
dummyRequestReceived.put("dummy", dummyUserIdList);
PairUp dummyPairUp = new PairUp("dummydummy", "dummy", "dummy", "dummy", dummyUserIdList);
HashMap<String, PairUp> dummyPairUps = new HashMap<>();
dummyPairUps.put("dummy", dummyPairUp);
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(instanceIdResult -> {
String deviceToken = instanceIdResult.getToken();
String url = "";
Uri photoUrl = user.getPhotoUrl();
if (photoUrl != null)
url = photoUrl.toString();
finalCurrentUser = new User(user.getUid(), user.getDisplayName(), url, user.getEmail(), dummyUserEntries, dummyRequestSent, dummyRequestReceived, deviceToken, true, dummyPairUps);
});
}
use of garbagecollectors.com.unipool.models.GenLocation in project UniPool by divya21raj.
the class BaseActivity method onActivityResult.
// +++++
// For NewEntryDialog
// A place has been received; use requestCode to track the request.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
Place place = PlaceAutocomplete.getPlace(this, data);
Log.e("Tag", "Place: " + place.getAddress() + place.getPhoneNumber());
LatLng latLng;
switch(requestCode) {
case 1:
latLng = place.getLatLng();
NewEntryDialog.source = new GenLocation(place.getName().toString(), place.getAddress().toString(), latLng.latitude, // check
latLng.longitude);
NewEntryDialog.sourceSet = (place.getName() + ",\n" + place.getAddress() + "\n" + // check
place.getPhoneNumber());
NewEntryDialog.findSource.setText(NewEntryDialog.sourceSet);
break;
case 2:
latLng = place.getLatLng();
NewEntryDialog.destination = new GenLocation(place.getName().toString(), place.getAddress().toString(), latLng.latitude, // check
latLng.longitude);
NewEntryDialog.destinationSet = (place.getName() + ",\n" + place.getAddress() + "\n" + // check
place.getPhoneNumber());
NewEntryDialog.findDestination.setText(NewEntryDialog.destinationSet);
break;
}
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(this, data);
// TODO: Handle the error.
Log.e("Tag", status.getStatusMessage());
} else if (resultCode == RESULT_CANCELED) {
// The user canceled the operation.
// Toast.makeText(getApplicationContext(), "Cancelled...", Toast.LENGTH_SHORT).show();
}
}
Aggregations