package com.xwkj.jcjcgz.mvp.presenter;

import android.app.Application;

import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader;

import me.jessyan.rxerrorhandler.core.RxErrorHandler;

import javax.inject.Inject;

import com.xwkj.jcjcgz.mvp.contract.TaskContract;
import com.xwkj.jcjcgz.mvp.model.api.CommonInterFace;
import com.xwkj.jcjcgz.mvp.model.api.ReqToBus;

import java.util.HashMap;
import java.util.Map;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 07/10/2024 15:13
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
@FragmentScope
public class TaskPresenter extends BasePresenter<TaskContract.Model, TaskContract.View> {
    @Inject
    RxErrorHandler mErrorHandler;
    @Inject
    Application mApplication;
    @Inject
    ImageLoader mImageLoader;
    @Inject
    AppManager mAppManager;

    @Inject
    public TaskPresenter(TaskContract.Model model, TaskContract.View rootView) {
        super(model, rootView);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mErrorHandler = null;
        this.mAppManager = null;
        this.mImageLoader = null;
        this.mApplication = null;
    }

    public void getList(Map<String,String> map){
        Map<String, Object> map1 = new HashMap<>();
        map1.put("mappingName", "/fzyj/pageByUser");
        map1.put("serviceName", "command-center");
        map1.put("params", map);
        ReqToBus.getInstance().init(mApplication).getRequestV2(map1, new CommonInterFace() {
            @Override
            public void onSuccess(String result) {
                if (mRootView != null) {
                    mRootView.onSuccess(result);
                }
            }

            @Override
            public void onError(Throwable throwable) {
            }

            @Override
            public void onFinsh() {

            }
        });
    }
}
