use of de.tum.in.tumcampusapp.api.app.TUMCabeClient in project TumCampusApp by TCA-Team.
the class FeedbackActivity method sendFeedback.
public void sendFeedback(View view) {
sentCount = 0;
stopListeningForLocation();
if (includeEmail.isChecked() && Strings.isNullOrEmpty(lrzId) && !isValidEmail()) {
return;
}
showProgressBarDialog();
TUMCabeClient client = TUMCabeClient.getInstance(this);
client.sendFeedback(getFeedback(), picPaths.toArray(new String[picPaths.size()]), new Callback<Success>() {
@Override
public void onResponse(Call<Success> call, Response<Success> response) {
Success success = response.body();
if (success != null && success.wasSuccessfullySent()) {
sentCount++;
Utils.log(success.getSuccess());
if (sentCount == picPaths.size() + 1) {
progress.cancel();
finish();
Toast.makeText(feedbackView.getContext(), R.string.feedback_send_success, Toast.LENGTH_SHORT).show();
}
Utils.log("sent " + sentCount + " of " + (picPaths.size() + 1) + " message parts");
} else {
showErrorDialog();
}
}
@Override
public void onFailure(Call<Success> call, Throwable t) {
showErrorDialog();
}
});
}
use of de.tum.in.tumcampusapp.api.app.TUMCabeClient in project TumCampusApp by TCA-Team.
the class WifiMeasurementManager method sendMeasurementsToRemote.
/**
* Calls the api-interface for storing the measurement data
*
* @param wifiMeasurements
* @throws IOException
*/
private void sendMeasurementsToRemote(List<WifiMeasurement> wifiMeasurements) throws IOException {
TUMCabeClient tumCabeClient = TUMCabeClient.getInstance(mContext);
tumCabeClient.createMeasurements(wifiMeasurements, new Callback<TUMCabeStatus>() {
@Override
public void onResponse(@NonNull Call<TUMCabeStatus> call, @NonNull Response<TUMCabeStatus> response) {
Utils.log("WifiMeasurements successfully sent to the server! " + response);
}
@Override
public void onFailure(@NonNull Call<TUMCabeStatus> call, @NonNull Throwable throwable) {
Utils.log("WifiMeasurements weren't sent to the server! " + throwable.getMessage());
}
});
}
use of de.tum.in.tumcampusapp.api.app.TUMCabeClient in project TumCampusApp by TCA-Team.
the class BarrierFreeFacilitiesActivity method onLoadInBackground.
@Override
protected Optional<List<RoomFinderRoom>> onLoadInBackground(Void... arg) {
showLoadingStart();
List<RoomFinderRoom> result;
TUMCabeClient cabeClient = TUMCabeClient.getInstance(this);
try {
switch(selectedFacilityPage) {
case 0:
// Nearby staff - need to fetch building id first
Optional<String> buildingId = locationManager.getBuildingIDFromCurrentLocation();
if (buildingId.isPresent()) {
result = cabeClient.getListOfNearbyFacilities(buildingId.get());
} else {
return Optional.absent();
}
break;
case 1:
result = cabeClient.getListOfToilets();
break;
case 2:
result = cabeClient.getListOfElevators();
break;
default:
return Optional.absent();
}
} catch (IOException e) {
Utils.log(e);
return Optional.absent();
}
if (result == null) {
return Optional.absent();
}
return Optional.of(result);
}
Aggregations