Search in sources :

Example 1 with TUMCabeClient

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();
        }
    });
}
Also used : TUMCabeClient(de.tum.in.tumcampusapp.api.app.TUMCabeClient) Success(de.tum.in.tumcampusapp.component.tumui.feedback.model.Success)

Example 2 with TUMCabeClient

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());
        }
    });
}
Also used : TUMCabeClient(de.tum.in.tumcampusapp.api.app.TUMCabeClient) TUMCabeStatus(de.tum.in.tumcampusapp.api.app.model.TUMCabeStatus)

Example 3 with TUMCabeClient

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);
}
Also used : RoomFinderRoom(de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom) TUMCabeClient(de.tum.in.tumcampusapp.api.app.TUMCabeClient) IOException(java.io.IOException)

Aggregations

TUMCabeClient (de.tum.in.tumcampusapp.api.app.TUMCabeClient)3 TUMCabeStatus (de.tum.in.tumcampusapp.api.app.model.TUMCabeStatus)1 Success (de.tum.in.tumcampusapp.component.tumui.feedback.model.Success)1 RoomFinderRoom (de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom)1 IOException (java.io.IOException)1