|  |  |  | 
|---|
|  |  |  | import android.os.Bundle; | 
|---|
|  |  |  | import android.os.Handler; | 
|---|
|  |  |  | import android.os.Message; | 
|---|
|  |  |  | import android.text.Editable; | 
|---|
|  |  |  | import android.text.SpannableString; | 
|---|
|  |  |  | import android.text.Spanned; | 
|---|
|  |  |  | import android.text.TextUtils; | 
|---|
|  |  |  | import android.text.TextWatcher; | 
|---|
|  |  |  | import android.text.style.TextAppearanceSpan; | 
|---|
|  |  |  | import android.view.View; | 
|---|
|  |  |  | import android.view.ViewTreeObserver; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.lib_coremodel.bean.event.ActionEventData; | 
|---|
|  |  |  | import com.doumee.lib_coremodel.util.SpUtil; | 
|---|
|  |  |  | import com.doumee.lib_coremodel.util.StringUtil; | 
|---|
|  |  |  | import com.doumee.lib_coremodel.view.ToastView; | 
|---|
|  |  |  | import com.example.datalibrary.callback.CameraDataCallback; | 
|---|
|  |  |  | import com.example.datalibrary.callback.FaceDetectCallBack; | 
|---|
|  |  |  | import com.example.datalibrary.gatecamera.CameraPreviewManager; | 
|---|
|  |  |  | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 1: | 
|---|
|  |  |  | //取-管理员刷卡验证 | 
|---|
|  |  |  | getDB().etEwm.setText(""); | 
|---|
|  |  |  | getDB().etEwm.requestFocus(); | 
|---|
|  |  |  | getDB().tvTitle.setText("管理员身份验证"); | 
|---|
|  |  |  | getDB().clFace.setVisibility(View.GONE); | 
|---|
|  |  |  | getDB().clCard.setVisibility(View.VISIBLE); | 
|---|
|  |  |  | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 3: | 
|---|
|  |  |  | //取-司机刷卡验证 | 
|---|
|  |  |  | getDB().etEwm.setText(""); | 
|---|
|  |  |  | getDB().etEwm.requestFocus(); | 
|---|
|  |  |  | getDB().tvTitle.setText("司机身份验证"); | 
|---|
|  |  |  | getDB().clFace.setVisibility(View.GONE); | 
|---|
|  |  |  | getDB().clSjXuan.setVisibility(View.GONE); | 
|---|
|  |  |  | 
|---|
|  |  |  | //开始检测 | 
|---|
|  |  |  | EventBus.getDefault().post(new JiujinBeginEvent()); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | ToastUtils.toast(this,"未获取到酒精浓度报警值"); | 
|---|
|  |  |  | ToastView.show(this,"未获取到酒精浓度报警值"); | 
|---|
|  |  |  | statusFsm(6); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 6: | 
|---|
|  |  |  | //取-司机酒精检测失败 | 
|---|
|  |  |  | Toast.makeText(mContext, "司机酒精检测失败", Toast.LENGTH_SHORT).show(); | 
|---|
|  |  |  | //Toast.makeText(mContext, "司机酒精检测失败", Toast.LENGTH_SHORT).show(); | 
|---|
|  |  |  | getDB().clJiu.setVisibility(View.GONE); | 
|---|
|  |  |  | getDB().tvJg1.setText("酒精检测异常,请重新检测"); | 
|---|
|  |  |  | getDB().clTip1.setVisibility(View.VISIBLE); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 7: | 
|---|
|  |  |  | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 8: | 
|---|
|  |  |  | //还-司机刷卡验证 | 
|---|
|  |  |  | getDB().etEwm.setText(""); | 
|---|
|  |  |  | getDB().etEwm.requestFocus(); | 
|---|
|  |  |  | getDB().tvTitle.setText("司机身份验证"); | 
|---|
|  |  |  | getDB().clFace.setVisibility(View.GONE); | 
|---|
|  |  |  | getDB().clCard.setVisibility(View.VISIBLE); | 
|---|
|  |  |  | setFaceModel(2); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 9: | 
|---|
|  |  |  | //取-司机酒精检测失败 | 
|---|
|  |  |  | getDB().clJiu.setVisibility(View.GONE); | 
|---|
|  |  |  | getDB().tvJg1.setText("酒精检测超标"); | 
|---|
|  |  |  | getDB().clTip1.setVisibility(View.VISIBLE); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | 
|---|
|  |  |  | case 5: | 
|---|
|  |  |  | statusFsm(4); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 6: | 
|---|
|  |  |  | //管理员ic卡成功 | 
|---|
|  |  |  | statusFsm(5); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 7: | 
|---|
|  |  |  | //司机ic卡成功 | 
|---|
|  |  |  | if(flag==0) { | 
|---|
|  |  |  | //取 | 
|---|
|  |  |  | statusFsm(4); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | //还 | 
|---|
|  |  |  | startActivity(KeyCabinetActivity.class); | 
|---|
|  |  |  | finish(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //ic卡读取 | 
|---|
|  |  |  | getDB().etEwm.requestFocus(); | 
|---|
|  |  |  | getDB().etEwm.setShowSoftInputOnFocus(false); | 
|---|
|  |  |  | getDB().etEwm.setFocusable(true); | 
|---|
|  |  |  | getDB().etEwm.setShowSoftInputOnFocus(true); | 
|---|
|  |  |  | hideSoftKeyboard(getDB().etEwm); | 
|---|
|  |  |  | getDB().etEwm.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onGlobalLayout() { | 
|---|
|  |  |  | hideSoftKeyboard(getDB().etEwm); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | getDB().etEwm.addTextChangedListener(new TextWatcher() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void beforeTextChanged(CharSequence s, int start, int count, int after) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onTextChanged(CharSequence s, int start, int before, int count) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void afterTextChanged(Editable s) { | 
|---|
|  |  |  | String m = s.toString(); | 
|---|
|  |  |  | if(TextUtils.isEmpty(m)){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(status!=1&&status!=3&&status!=8){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(handler.hasMessages(5)){ | 
|---|
|  |  |  | handler.removeMessages(5); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | handler.sendEmptyMessageDelayed(5,500); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | //isCheckFace = false; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 3: | 
|---|
|  |  |  | Toast.makeText(mContext, "酒精检查返回", Toast.LENGTH_SHORT).show(); | 
|---|
|  |  |  | getDB().clJiujinProgress.setVisibility(View.GONE); | 
|---|
|  |  |  | //Toast.makeText(mContext, "酒精检查返回", Toast.LENGTH_SHORT).show(); | 
|---|
|  |  |  | if(new BigDecimal(MApplication.getConfigBean().getCabinetConfigDataVO().getConcentration()) | 
|---|
|  |  |  | .compareTo(resultEvent.getConcentration())>=0){ | 
|---|
|  |  |  | //酒精通过 | 
|---|
|  |  |  | 
|---|
|  |  |  | handler.sendEmptyMessageDelayed(4,1000); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | //酒精不通过 | 
|---|
|  |  |  | getVM().alcoholTestAlarm(""); | 
|---|
|  |  |  | Toast.makeText(mContext, "酒精检测不通过", Toast.LENGTH_SHORT).show(); | 
|---|
|  |  |  | statusFsm(6); | 
|---|
|  |  |  | getVM().alcoholTestAlarm(resultEvent.getConcentration().toString()); | 
|---|
|  |  |  | //Toast.makeText(mContext, "酒精检测超标", Toast.LENGTH_SHORT).show(); | 
|---|
|  |  |  | statusFsm(9); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 4: | 
|---|
|  |  |  | startActivity(KeyCabinetActivity.class); | 
|---|
|  |  |  | finish(); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 5: | 
|---|
|  |  |  | String m = getDB().etEwm.getText().toString(); | 
|---|
|  |  |  | int index = m.indexOf("\r"); | 
|---|
|  |  |  | if(index!=-1){ | 
|---|
|  |  |  | m = m.substring(0,index); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!TextUtils.isEmpty(m)){ | 
|---|
|  |  |  | getVM().getMemberIdByCode(m,status==1?"0":"1"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | getDB().etEwm.setText(""); | 
|---|
|  |  |  | getDB().etEwm.requestFocus(); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!isFinishing()){ | 
|---|
|  |  |  | //Toast.makeText(mContext, "酒精检测返回:"+e.isOk(), Toast.LENGTH_SHORT).show(); | 
|---|
|  |  |  | if(!e.isOk()){ | 
|---|
|  |  |  | getDB().clJiujinProgress.setVisibility(View.GONE); | 
|---|
|  |  |  | statusFsm(6); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | getDB().clJiujinProgress.setVisibility(View.VISIBLE); | 
|---|
|  |  |  | if(resultEvent==null){ | 
|---|
|  |  |  | resultEvent = e; | 
|---|
|  |  |  | }else if(resultEvent.getConcentration().compareTo(e.getConcentration())<0){ | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|