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

import android.content.Context;

import com.gaoyuan.weixinrecord.example.Record;
import com.tofly.ghrq_route.module.message.service.IMessageService;
import com.tofly.ghrq_route.module.message.service.MessageServiceImpl;
import com.tofly.ghrq_route.module.trouble.domain.TroubleBean;
import com.tofly.ghrq_route.module.trouble.domain.TroublePictureBean;

import java.util.List;

/**
 * Created by Amu on 2017/5/3.
 */

public class MessageController {
    /**
     * 是否在綫
     */
    boolean mbOnline;
    /**
     * 上下文
     */
    Context mContext;
    /**
     * Trouble接口实现对象
     */
    IMessageService messageService;

    public MessageController(Context context) {
        mbOnline = true;
        mContext = context;
        messageService = new MessageServiceImpl(context);
    }

    public MessageController(boolean online, Context context) {
        mbOnline = online;
        mContext = context;
        messageService = new MessageServiceImpl(context);
    }

    /**
     * 获取接收消息列表
     *
     * @param token
     * @param pageindex       当前页index
     * @param pagesize        每页数据大小
     * @param messageCallBack
     */
    public void getRecvMsgList(String token, int isread, int pageindex, int pagesize, MessageCallBack messageCallBack) {
        messageService.getRecvMsgList(token, isread, pageindex, pagesize, messageCallBack);
    }

    public void getRecvMsgList1(String token, int isread, int pageindex, int pagesize, String content, MessageCallBack messageCallBack) {
        messageService.getRecvMsgList1(token, isread, pageindex, pagesize, content, messageCallBack);
    }

    /**
     * 获取发送消息列表
     *
     * @param token
     * @param pageindex       当前页index
     * @param pagesize        每页数据大小
     * @param messageCallBack
     */
    public void getSendMsgList(String token, int pageindex, int pagesize, String content, MessageCallBack messageCallBack) {
        messageService.getSendMsgList(token, pageindex, pagesize, content, messageCallBack);
    }

    /**
     * 获取消息详情
     *
     * @param messageCallBack
     * @param id              消息id
     */
    public void getMsgDetail(String id, MessageCallBack messageCallBack) {
        messageService.getMsgDetail(id, messageCallBack);
    }

    /**
     * 设置接受消息已读
     *
     * @param token
     * @param ids             已读消息的id，多个或单个
     * @param messageCallBack
     */
    public void setRecvMsgReaded(String token, String ids, MessageCallBack messageCallBack) {
        messageService.setRecvMsgReaded(token, ids, messageCallBack);
    }

    /**
     * 删除接受消息
     *
     * @param token
     * @param ids             消息的id，多个或单个
     * @param messageCallBack
     */
    public void deleteRecvMsg(String token, String ids, MessageCallBack messageCallBack) {
        messageService.deleteRecvMsg(token, ids, messageCallBack);
    }

    /**
     * 删除发送消息
     *
     * @param token
     * @param ids             消息的id，多个或单个
     * @param messageCallBack
     */
    public void deleteSendMsg(String token, String ids, MessageCallBack messageCallBack) {
        messageService.deleteSendMsg(token, ids, messageCallBack);
    }

    /**
     * 发送消息
     *
     * @param
     * @param receipt         接收人id,多个以逗号隔开，如：user1,user2,user3[必填]
     * @param message         消息内容
     * @param messageCallBack
     */
    public void sendMsg(int id, String message, String receipt, List<TroublePictureBean> photos, List<Record> audios, MessageCallBack messageCallBack) {
        messageService.sendMsg(id, message, receipt, photos, audios, messageCallBack);
    }

    /**
     * 发送求救消息
     *
     * @param token
     * @param trouble         求救时所在的地址，经纬度，和描述信息
     * @param photos          上传的图片
     * @param audios          上传的录音
     * @param messageCallBack
     */
    public void sendHelpMsg(String token, TroubleBean trouble, List<TroublePictureBean> photos, List<Record> audios, MessageCallBack messageCallBack) {
        messageService.sendHelpMsg(token, trouble, photos, audios, messageCallBack);
    }
}
