package com.cooleshow.student.presenter.course;

import com.cooleshow.base.presenter.BasePresenter;
import com.cooleshow.base.rx.BaseObserver;
import com.cooleshow.base.utils.RequestBodyUtil;
import com.cooleshow.student.api.APIService;
import com.cooleshow.student.bean.PianoRoomCourseHomeworkBean;
import com.cooleshow.student.bean.SparringCourseCommentBean;
import com.cooleshow.student.bean.SparringCourseHomeworkBean;
import com.cooleshow.student.contract.PianoRoomCourseDetailContract;
import com.cooleshow.student.contract.SparringCourseDetailContract;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Author by pq, Date on 2022/4/27.
 */
public class PianoRoomCourseDetailPresenter extends BasePresenter<PianoRoomCourseDetailContract.PianoRoomCourseDetailView> implements PianoRoomCourseDetailContract.Presenter {

    @Override
    public void getPianoRoomCourseInfo(String courseId) {
        if (getView() != null) {
            getView().showLoading();
        }
        addSubscribe(create(APIService.class).getPianoRoomCourseHomework(courseId), new BaseObserver<PianoRoomCourseHomeworkBean>(getView()) {
            @Override
            protected void onSuccess(PianoRoomCourseHomeworkBean data) {
                if (getView() != null) {
                    getView().getPianoRoomCourseSuccess(data);
                }
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                if (getView() != null) {
                    getView().getPianoRoomCourseHomeworkError();
                }
            }
        });
    }
}
