package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.ActionResultBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.UploadVideoModelImpl;
import com.casic.dcms.mvp.view.IUploadFileView;

import java.io.File;

public class UploadVideoPresenterImpl extends BasePresenter implements IUploadFilePresenter, UploadVideoModelImpl.OnUploadVideoListener {

    private IUploadFileView view;
    private UploadVideoModelImpl actionModel;

    public UploadVideoPresenterImpl(IUploadFileView uploadVideoView) {
        this.view = uploadVideoView;
        actionModel = new UploadVideoModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(File file) {
        view.showProgress();
        addSubscription(actionModel.sendRetrofitRequest(file));
    }

    @Override
    public void onSuccess(ActionResultBean resultBean) {
        view.hideProgress();
        view.obtainUploadVideoResult(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {
        view.hideProgress();
        view.obtainDataFail();
    }

    @Override
    public void disposeRetrofitRequest() {
        unSubscription();
    }
}
