package cn.net.caoyao.cpzshandset.service.tools;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import cilico.tools.barcode.PhoneCilicoSoundUtils;
import cilico.tools.barcode.PhoneScanner;
import cn.net.caoyao.cpzshandset.ui.weight.DialogUtils;

public class BaseHandler extends Handler {
	private Context mContext;
	public BaseHandler(Context mContext) {
		this.mContext = mContext;
	}
	private static final int base= 10000; 
	//无网络状态
	public static final int netNo = base+1; 
	//网络连接失败
	public static final int netErr = base+2; 
	//登录失败
	public static final int loginErr = base+3; 
	//扫描错误信息
	public static final int scanErrLabel =PhoneScanner.BARCODE_ERR_LABEL; 
	@Override
	public void handleMessage(Message msg) {
		int id = msg.what;
		switch (id) {
		case netNo:
			DialogUtils.showSetNetDialog(mContext);
			break;
		case netErr:
			DialogUtils.ShowMsgDialog(mContext, msg.obj.toString());
			break;
		case loginErr:
			DialogUtils.ShowMsgDialog(mContext, msg.obj.toString());
			break;
		case scanErrLabel:
			PhoneCilicoSoundUtils.play();
			DialogUtils.ShowMsgDialog(mContext, "扫描异常:\n"+msg.obj.toString());
			break;

		default:
			super.handleMessage(msg);
			break;
		}
	}
}
