package com.bc_chat.bc_base.presenter;

import com.bc_chat.bc_base.contract.UpLoadPictureContract;
import com.bc_chat.bc_base.task.UpLoadPictureAsyncTask;
import com.zhaohaoting.framework.abs.presenter.BasePresenter;
import com.zhaohaoting.framework.requset.NetWorkCallBack;

import java.util.List;

/**
 * author：Created by zhaohaoting on 2019/3/5
 * email：526309416@qq.com
 * desc：上传图片
 */
public class UpLoadPicturePresenter<VIEW extends UpLoadPictureContract.View> extends BasePresenter<VIEW> implements UpLoadPictureContract.Presenter {

    public UpLoadPicturePresenter(VIEW view) {
        super(view);
    }

    @Override
    public void upload(List<String> paths) {
        taskHelper.execute(new UpLoadPictureAsyncTask(paths), new NetWorkCallBack<List<String>>() {
            @Override
            public void onPreExecute(Object task) {
                super.onPreExecute(task);
                getView().showLoading(task);
            }

            @Override
            protected void onPostExecuteSuccess(Object task, List<String> strings) {
                getView().dismissLoading(task);
                getView().uploadSuccess(strings);
            }

            @Override
            protected void onPostExecuteFailure(Object task, Exception exception) {
                getView().dismissLoading(task);
                getView().uploadFailure(exception);
            }
        });
    }
}
