package cn.net.caoyao.cpzshandset.service.presenter.impl.upload.ythScanner;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;

import cn.net.caoyao.cpzshandset.common.config.TConfig;
import cn.net.caoyao.cpzshandset.common.util.LogUtil;
import cn.net.caoyao.cpzshandset.service.bll.ShipmentUploadStatusBll;
import cn.net.caoyao.cpzshandset.service.presenter.UploadStatusConstact;
import cn.net.caoyao.cpzshandset.service.presenter.base.impl.UploadStatusConstactImpl;
import cn.net.caoyao.cpzshandset.ui.adapter.ShipmentUploadStatusAdapter;

public class YthScannerUploadStatusPresenter extends UploadStatusConstactImpl{

	private final UploadStatusConstact.View uView;
	private Context context;
	private List<String> dates = new ArrayList<>();
	private ShipmentUploadStatusBll uploadStatusBll;
	public YthScannerUploadStatusPresenter(UploadStatusConstact.View uView,Context context) {
		this.uView = uView;
		this.context = context;
		start();
	}
	
	@Override
	public void start() {
		if (!checkViewAvailable()) return;
		init();
		uView.setPageTitle("上传记录");
		uView.setAdapter(new ShipmentUploadStatusAdapter(dates, uploadStatusBll));
	}

	private void init() {
		uploadStatusBll = new ShipmentUploadStatusBll(context);
		dates = uploadStatusBll.queryUploadDateFor7Days();
		LogUtil.d(TConfig.Echo, "提交状态：" + dates.toString());
	}

	@Override
	public boolean checkViewAvailable() {
		boolean b = false;
        if (uView != null && context != null) {
            b = true;
        }
        return b;
	}



}
