package com.tofly.ghrq_route.module.sketch.service;

import android.content.Context;

import com.tofly.ghrq_route.base.URLResponseCode;
import com.tofly.ghrq_route.module.sketch.SketchDaoHelper;
import com.tofly.ghrq_route.module.sketch.controller.SketchCallback;
import com.tofly.ghrq_route.module.sketch.domain.SketchBean;
import com.tofly.ghrq_route.module.sketch.domain.SketchBean.SKETCH_TASK_STATUS;

import java.util.List;

public class SketchServiceImplOffline implements ISketchService {

    private SketchDaoHelper sketchDaoHelper;

    public SketchServiceImplOffline() {
        sketchDaoHelper = SketchDaoHelper.getInstance();
    }

    @Override
    public void getSketchList(Context context, String userid, int sketch_state, int pageindex, int pagesize, SketchCallback sketchCallback) {
        int total = 0;
        List<SketchBean> sketchBeans;
        if (sketch_state == 0){
            sketchBeans = sketchDaoHelper.getSketchList(userid);
        }else {
            int state = SKETCH_TASK_STATUS.SKETCH_TASK_UNCOMMIT.getStatus();
            switch (sketch_state){
                case 1:
                    state = SKETCH_TASK_STATUS.SKETCH_TASK_UNCOMMIT.getStatus();
                    break;
                case 2:
                    state = SKETCH_TASK_STATUS.SKETCH_TASK_COMMITED.getStatus();
                    break;
            }
            sketchBeans = sketchDaoHelper.getSketchList(userid, state);
        }
        if (sketchBeans != null) {
            total = sketchBeans.size();
        }
        sketchCallback.onGetSketchList(true, URLResponseCode.ErrorCode.SUCCESS_OFFLINE, "", sketchBeans, total);
    }

    @Override
    public void uploadSketchData(Context context, SketchBean sketchBean, SketchCallback sketchCallback) {

    }

    @Override
    public void getSketchData(Context context, String sketch_id, SketchCallback sketchCallback) {

    }
}
