package com.ahau.againstpestinfo.presenter;

import com.ahau.againstpestinfo.model.ISearchModel;
import com.ahau.againstpestinfo.model.ISearchModelImpl;
import com.ahau.againstpestinfo.view.ISearchView;

import java.util.List;

/**
 * 注释:
 *
 * @author fanchunchun
 * @date 2018/4/6
 */

public class ISearchPresenter<T extends ISearchView> extends BasePresenter<T>{
    //拿到model层的引用
    ISearchModel searchModel = new ISearchModelImpl();

    //构造方法
    public ISearchPresenter() {

    }

    /**
     *
     */
    //执行UI逻辑
    public void fetch(){
        if (mViewRef.get() != null) {
            if (searchModel != null) {
                //设置调查人姓名
                searchModel.getResearName(new ISearchModel.ResearNameListener() {
                    @Override
                    public void onComplete(List<String> researName) {
                        if (mViewRef.get() != null) {
                            mViewRef.get().setResearName(researName);
                        }
                    }
                });

                //设置查询时间
                searchModel.getAreaid(new ISearchModel.DateListener() {
                    @Override
                    public void onComplete(List<String> date) {
                        if (mViewRef.get() != null) {
                            mViewRef.get().setAreaid(date);
                        }
                    }
                });

            }
        }
    }
}
