Search in sources :

Example 1 with Feedback

use of com.xinshang.audient.model.entities.Feedback in project Audient by komamj.

the class FeedbackPresenter method sendFeedback.

@Override
public void sendFeedback(String title, String content) {
    if (isInValid(title, content)) {
        return;
    }
    if (mView.isActive()) {
        mView.setLoadingIndicator(true);
    }
    Feedback feedback = new Feedback();
    feedback.title = title;
    feedback.content = content;
    Disposable disposable = mRepository.sendFeedback(feedback).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSubscriber<ApiResponse>() {

        @Override
        public void onNext(ApiResponse apiResponse) {
            if (apiResponse.resultCode == 0) {
                mView.showSuccessfulMessage();
            } else {
                mView.showFailedMessage();
            }
        }

        @Override
        public void onError(Throwable t) {
            LogUtils.e(TAG, "sendFeedback error : " + t.getMessage());
            if (mView.isActive()) {
                mView.setLoadingIndicator(false);
            }
        }

        @Override
        public void onComplete() {
            if (mView.isActive()) {
                mView.setLoadingIndicator(false);
            }
        }
    });
    mDisposables.add(disposable);
}
Also used : CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) Feedback(com.xinshang.audient.model.entities.Feedback) ApiResponse(com.xinshang.audient.model.entities.ApiResponse)

Aggregations

ApiResponse (com.xinshang.audient.model.entities.ApiResponse)1 Feedback (com.xinshang.audient.model.entities.Feedback)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 Disposable (io.reactivex.disposables.Disposable)1