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

import android.content.Context;
import com.tofly.ghrq_route.module.sketch.domain.SketchBean;
import com.tofly.ghrq_route.module.sketch.service.ISketchService;
import com.tofly.ghrq_route.module.sketch.service.SketchServiceImpl;
import com.tofly.ghrq_route.module.sketch.service.SketchServiceImplOffline;

public class SketchController {

    ISketchService sketchService;

    public SketchController() {

    }

    private void setService(boolean online){
        if (online){
            sketchService = new SketchServiceImpl();
        }else {
            sketchService = new SketchServiceImplOffline();
        }
    }

    /**
     *  获取草图列表
     */
    public void getSketchList(Context context, String userid, int sketch_state, int pageindex, int pagesize, boolean online, final SketchCallback sketchCallback) {
        setService(online);
        sketchService.getSketchList(context, userid, sketch_state, pageindex, pagesize, sketchCallback);
    }

    /**
     *  上传草图信息
     * @param sketchBean 草图信息数据
     * @param sketchCallback
     */
    public void uploadSketchData(Context context, SketchBean sketchBean, final SketchCallback sketchCallback){
        setService(true);
        sketchService.uploadSketchData(context, sketchBean, sketchCallback);
    }

    /**
     *  获取草图详情
     * @param sketch_id 草图id
     */
    public void getSketchData(Context context, String sketch_id, boolean online, SketchCallback sketchCallback) {
        setService(online);
        sketchService.getSketchData(context, sketch_id, sketchCallback);
    }
}
