Search in sources :

Example 1 with Success

use of de.tum.in.tumcampusapp.component.tumui.feedback.model.Success 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)

Aggregations

TUMCabeClient (de.tum.in.tumcampusapp.api.app.TUMCabeClient)1 Success (de.tum.in.tumcampusapp.component.tumui.feedback.model.Success)1