use of garbagecollectors.com.unipool.GenLocation in project UniPool by divya21raj.
the class NewEntryActivity method getCurrentPlace.
private void getCurrentPlace() {
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(getApplicationContext(), "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.GenLocation in project UniPool by divya21raj.
the class LoginActivity method dummyInitFinalCurrentUser.
private void dummyInitFinalCurrentUser(FirebaseUser user) throws ParseException {
HashMap<String, Float> dummyLambdaMap = new HashMap<>();
dummyLambdaMap.put("123", 0f);
GenLocation dummyGenLocation = new GenLocation("dummy", "dummy", 0d, 0d);
TripEntry dummyTripEntry = new TripEntry("dummy", "dummyId", "DummyUser", "12:00", "1/11/12", dummyGenLocation, dummyGenLocation, dummyLambdaMap);
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);
Message dummyMessage = new Message("dummy", "", "", "dummy", "dummy", 1L);
ArrayList<Message> dummyMessages = new ArrayList<>();
dummyMessages.add(dummyMessage);
PairUp dummyPairUp = new PairUp("dummydummy", "dummy", "dummy", "dummy", dummyUserIdList);
HashMap<String, PairUp> dummyPairUps = new HashMap<>();
dummyPairUps.put("dummy", dummyPairUp);
String deviceToken = FirebaseInstanceId.getInstance().getToken();
String url = "";
Uri photoUrl = user.getPhotoUrl();
if (photoUrl != null)
url = photoUrl.toString();
finalCurrentUser = new User(user.getUid(), user.getDisplayName(), url, dummyUserEntries, dummyRequestSent, dummyRequestReceived, deviceToken, true, dummyPairUps);
}
use of garbagecollectors.com.unipool.GenLocation in project UniPool by divya21raj.
the class NewEntryActivity method onActivityResult.
// A place has been received; use requestCode to track the request.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == 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();
source = new GenLocation(place.getName().toString(), place.getAddress().toString(), latLng.latitude, // check
latLng.longitude);
sourceSet = (place.getName() + ",\n" + place.getAddress() + "\n" + // check
place.getPhoneNumber());
findSource.setText(sourceSet);
break;
case 2:
latLng = place.getLatLng();
destination = new GenLocation(place.getName().toString(), place.getAddress().toString(), latLng.latitude, // check
latLng.longitude);
destinationSet = (place.getName() + ",\n" + place.getAddress() + "\n" + // check
place.getPhoneNumber());
findDestination.setText(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