|  |  | 
 |  |  | import android.os.Bundle; | 
 |  |  | import android.os.Handler; | 
 |  |  | import android.os.Message; | 
 |  |  | import android.text.SpannableString; | 
 |  |  | import android.text.Spanned; | 
 |  |  | import android.text.TextUtils; | 
 |  |  | import android.text.style.TextAppearanceSpan; | 
 |  |  | import android.view.View; | 
 |  |  | import android.view.ViewTreeObserver; | 
 |  |  | import android.view.inputmethod.InputMethodManager; | 
 |  |  | import android.widget.TextView; | 
 |  |  | import android.widget.Toast; | 
 |  |  |  | 
 |  |  | import com.baidu.idl.main.facesdk.model.BDFaceSDKCommon; | 
 |  |  | import com.doumee.keyCabinet.MApplication; | 
 |  |  | import com.doumee.keyCabinet.R; | 
 |  |  | import com.doumee.keyCabinet.base.MyBaseActivity; | 
 |  |  | import com.doumee.keyCabinet.databinding.FaceActivityBinding; | 
 |  |  | import com.doumee.keyCabinet.event.FaceStatusChangeEvent; | 
 |  |  | import com.doumee.keyCabinet.event.JiujinBeginEvent; | 
 |  |  | import com.doumee.keyCabinet.event.JiujinResultEvent; | 
 |  |  | import com.doumee.keyCabinet.event.TimeClockEvent; | 
 |  |  | import com.doumee.keyCabinet.ui.keyCabinet.KeyCabinetActivity; | 
 |  |  | import com.doumee.keyCabinet.utils.BraceletLogUtils; | 
 |  |  | 
 |  |  | import com.doumee.keyCabinet.utils.face.model.SingleBaseConfig; | 
 |  |  | import com.doumee.lib_coremodel.bean.event.ActionEventData; | 
 |  |  | import com.doumee.lib_coremodel.util.SpUtil; | 
 |  |  | import com.doumee.lib_coremodel.util.StringUtil; | 
 |  |  | import com.example.datalibrary.callback.CameraDataCallback; | 
 |  |  | import com.example.datalibrary.callback.FaceDetectCallBack; | 
 |  |  | import com.example.datalibrary.gatecamera.CameraPreviewManager; | 
 |  |  | 
 |  |  | import com.example.datalibrary.model.LivenessModel; | 
 |  |  | import com.example.datalibrary.model.User; | 
 |  |  | import com.example.datalibrary.utils.FaceOnDrawTexturViewUtil; | 
 |  |  | import com.example.datalibrary.utils.ToastUtils; | 
 |  |  |  | 
 |  |  | import org.greenrobot.eventbus.EventBus; | 
 |  |  | import org.greenrobot.eventbus.Subscribe; | 
 |  |  | import org.greenrobot.eventbus.ThreadMode; | 
 |  |  |  | 
 |  |  | import java.math.BigDecimal; | 
 |  |  |  | 
 |  |  | import dagger.hilt.android.AndroidEntryPoint; | 
 |  |  |  | 
 |  |  | 
 |  |  |         getDB().setModel(getVM()); | 
 |  |  |         mContext = this; | 
 |  |  |         flag = MApplication.getLoginBean().getFlag(); | 
 |  |  |         statusFsm(flag==0?0:2); | 
 |  |  |         //todo wmf 解开 | 
 |  |  |         /*FaceSDKManager.getInstance().initDataBases(this); | 
 |  |  |         initFaceCheck();*/ | 
 |  |  |         FaceSDKManager.getInstance().initDataBases(this); | 
 |  |  |         initFaceCheck(); | 
 |  |  |         initView(); | 
 |  |  |         if(flag==0){ | 
 |  |  |             if(MApplication.getConfigBean().getDoubleAuth()==1){ | 
 |  |  |                 statusFsm(0); | 
 |  |  |             }else { | 
 |  |  |                 statusFsm(2); | 
 |  |  |             } | 
 |  |  |         }else { | 
 |  |  |             statusFsm(7); | 
 |  |  |         } | 
 |  |  |         getDB().tvDjs.setOnClickListener(new View.OnClickListener() { | 
 |  |  |             @Override | 
 |  |  |             public void onClick(View v) { | 
 |  |  |                 statusFsm(status); | 
 |  |  |             } | 
 |  |  |         }); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |         getDB().tvDjs.setText(djs); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private SpannableString getErrPhoneText(){ | 
 |  |  |         String phone = MApplication.getConfigBean().getLinkPhone(); | 
 |  |  |         String text = "如有问题请联系管理员"+phone; | 
 |  |  |         SpannableString styledText = new SpannableString(text); | 
 |  |  |         styledText.setSpan(new TextAppearanceSpan(this, R.style.style_tip3), 0, text.length()-phone.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); | 
 |  |  |         styledText.setSpan(new TextAppearanceSpan(this,R.style.style_tip1), text.length()-phone.length()+1, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); | 
 |  |  |         return styledText; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void statusFsm(int toStatus){ | 
 |  |  |         status = toStatus; | 
 |  |  |         switch (status){ | 
 |  |  |         isToChose = false; | 
 |  |  |         switch (toStatus){ | 
 |  |  |             case 0: | 
 |  |  |                 //取-管理员人脸验证 | 
 |  |  |                 getDB().clLogin.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().tvTitle.setText("管理员身份验证"); | 
 |  |  |                 getDB().vSl.setBackgroundResource(R.mipmap.ic_viewfinder); | 
 |  |  |                 getDB().tvTip.setText("请保持正脸在取景框中,并根据指示完成识别"); | 
 |  |  |                 getDB().clRemind.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().btSk.setVisibility(View.VISIBLE); | 
 |  |  |  | 
 |  |  |                 getDB().clSjRl.setVisibility(View.GONE); | 
 |  |  |                 getDB().clSjSk.setVisibility(View.GONE); | 
 |  |  |                 getDB().clTip1.setVisibility(View.GONE); | 
 |  |  |                 getDB().clCard.setVisibility(View.GONE); | 
 |  |  |                 getDB().clFace.setVisibility(View.VISIBLE); | 
 |  |  |                 setFaceModel(0); | 
 |  |  |                 break; | 
 |  |  |             case 1: | 
 |  |  |                 //取-管理员刷卡验证 | 
 |  |  |                 getDB().clLogin.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().tvTitle.setText("管理员身份验证"); | 
 |  |  |                 getDB().vSl.setBackgroundResource(R.mipmap.ic_shuaka2); | 
 |  |  |                 getDB().tvTip.setText("请将IC卡贴近刷卡区,停留1-2秒"); | 
 |  |  |                 getDB().clRemind.setVisibility(View.GONE); | 
 |  |  |                 getDB().btSk.setVisibility(View.GONE); | 
 |  |  |  | 
 |  |  |                 getDB().clSjRl.setVisibility(View.GONE); | 
 |  |  |                 getDB().clSjSk.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().clTip1.setVisibility(View.GONE); | 
 |  |  |                 getDB().clFace.setVisibility(View.GONE); | 
 |  |  |                 getDB().clCard.setVisibility(View.VISIBLE); | 
 |  |  |                 setFaceModel(2); | 
 |  |  |                 break; | 
 |  |  |             case 5: | 
 |  |  |                 //取-司机验证方式选择页 | 
 |  |  |                 getDB().clLogin.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().tvTitle.setText("司机身份验证"); | 
 |  |  |                 getDB().vSl.setBackgroundResource(R.mipmap.ic_face); | 
 |  |  |                 getDB().tvTip.setText("请保持正脸在取景框中,并根据指示完成识别"); | 
 |  |  |                 getDB().clRemind.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().btSk.setVisibility(View.GONE); | 
 |  |  |  | 
 |  |  |                 getDB().clSjRl.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().clSjSk.setVisibility(View.GONE); | 
 |  |  |                 getDB().clFace.setVisibility(View.GONE); | 
 |  |  |                 getDB().clCard.setVisibility(View.GONE); | 
 |  |  |                 getDB().clTip1.setVisibility(View.GONE); | 
 |  |  |                 getDB().clSjXuan.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().clSjXuan.invalidate(); | 
 |  |  |                 getDB().clSjXuan.requestLayout(); | 
 |  |  |                 break; | 
 |  |  |             case 2: | 
 |  |  |                 //取-司机人脸验证 | 
 |  |  |                 getDB().clLogin.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().tvTitle.setText("司机身份验证"); | 
 |  |  |                 getDB().vSl.setBackgroundResource(R.mipmap.ic_viewfinder); | 
 |  |  |                 getDB().tvTip.setText("请保持正脸在取景框中,并根据指示完成识别"); | 
 |  |  |                 getDB().clRemind.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().btSk.setVisibility(View.VISIBLE); | 
 |  |  |  | 
 |  |  |                 getDB().clSjRl.setVisibility(View.GONE); | 
 |  |  |                 getDB().clSjSk.setVisibility(View.GONE); | 
 |  |  |                 getDB().clTip1.setVisibility(View.GONE); | 
 |  |  |                 getDB().clCard.setVisibility(View.GONE); | 
 |  |  |                 getDB().clSjXuan.setVisibility(View.GONE); | 
 |  |  |                 getDB().clFace.setVisibility(View.VISIBLE); | 
 |  |  |                 setFaceModel(1); | 
 |  |  |                 break; | 
 |  |  |             case 3: | 
 |  |  |                 //取-司机刷卡验证 | 
 |  |  |                 getDB().clLogin.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().tvTitle.setText("司机身份验证"); | 
 |  |  |                 getDB().vSl.setBackgroundResource(R.mipmap.ic_shuaka2); | 
 |  |  |                 getDB().tvTip.setText("请将IC卡贴近刷卡区,停留1-2秒"); | 
 |  |  |                 getDB().clRemind.setVisibility(View.GONE); | 
 |  |  |                 getDB().btSk.setVisibility(View.GONE); | 
 |  |  |  | 
 |  |  |                 getDB().clSjRl.setVisibility(View.GONE); | 
 |  |  |                 getDB().clSjSk.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().clTip1.setVisibility(View.GONE); | 
 |  |  |                 getDB().clFace.setVisibility(View.GONE); | 
 |  |  |                 getDB().clSjXuan.setVisibility(View.GONE); | 
 |  |  |                 getDB().clCard.setVisibility(View.VISIBLE); | 
 |  |  |                 setFaceModel(2); | 
 |  |  |                 break; | 
 |  |  |             case 4: | 
 |  |  |                 //取-司机酒精检测 | 
 |  |  |                 getDB().clLogin.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().tvTitle.setText("酒精检测"); | 
 |  |  |                 getDB().vSl.setBackgroundResource(R.mipmap.ic_jiujingjiance); | 
 |  |  |                 getDB().tvTip.setText("请拿起酒精检测仪吹气"); | 
 |  |  |                 getDB().clRemind.setVisibility(View.GONE); | 
 |  |  |                 getDB().btSk.setVisibility(View.GONE); | 
 |  |  |  | 
 |  |  |                 getDB().clSjRl.setVisibility(View.GONE); | 
 |  |  |                 getDB().clSjSk.setVisibility(View.GONE); | 
 |  |  |                 getDB().clFace.setVisibility(View.GONE); | 
 |  |  |                 getDB().clCard.setVisibility(View.GONE); | 
 |  |  |                 getDB().clSjXuan.setVisibility(View.GONE); | 
 |  |  |                 getDB().clTip1.setVisibility(View.GONE); | 
 |  |  |                 getDB().clJiu.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().clJiu.invalidate(); | 
 |  |  |                 getDB().clJiu.requestLayout(); | 
 |  |  |                 if(MApplication.getConfigBean()!=null&&MApplication.getConfigBean().getCabinetConfigDataVO()!=null&& | 
 |  |  |                         MApplication.getConfigBean().getCabinetConfigDataVO().getConcentration()!=null){ | 
 |  |  |                     //开始检测 | 
 |  |  |                     EventBus.getDefault().post(new JiujinBeginEvent()); | 
 |  |  |                 }else { | 
 |  |  |                     ToastUtils.toast(this,"未获取到酒精浓度报警值"); | 
 |  |  |                     statusFsm(6); | 
 |  |  |                 } | 
 |  |  |                 break; | 
 |  |  |             case 6: | 
 |  |  |                 //取-司机酒精检测失败 | 
 |  |  |                 Toast.makeText(mContext, "司机酒精检测失败", Toast.LENGTH_SHORT).show(); | 
 |  |  |                 getDB().clJiu.setVisibility(View.GONE); | 
 |  |  |                 getDB().clTip1.setVisibility(View.VISIBLE); | 
 |  |  |                 break; | 
 |  |  |             case 7: | 
 |  |  |                 //还-司机人脸验证 | 
 |  |  |                 getDB().clLogin.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().tvTitle.setText("司机身份验证"); | 
 |  |  |                 getDB().vSl.setBackgroundResource(R.mipmap.ic_viewfinder); | 
 |  |  |                 getDB().tvTip.setText("请保持正脸在取景框中,并根据指示完成识别"); | 
 |  |  |                 getDB().clRemind.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().btSk.setVisibility(View.VISIBLE); | 
 |  |  |  | 
 |  |  |                 getDB().clSjSk.setVisibility(View.GONE); | 
 |  |  |                 getDB().clSjRl.setVisibility(View.GONE); | 
 |  |  |                 getDB().clTip1.setVisibility(View.GONE); | 
 |  |  |                 getDB().clCard.setVisibility(View.GONE); | 
 |  |  |                 getDB().clFace.setVisibility(View.VISIBLE); | 
 |  |  |                 setFaceModel(1); | 
 |  |  |                 break; | 
 |  |  |             case 8: | 
 |  |  |                 //还-司机刷卡验证 | 
 |  |  |                 getDB().clLogin.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().tvTitle.setText("司机身份验证"); | 
 |  |  |                 getDB().vSl.setBackgroundResource(R.mipmap.ic_shuaka2); | 
 |  |  |                 getDB().tvTip.setText("请将IC卡贴近刷卡区,停留1-2秒"); | 
 |  |  |                 getDB().clRemind.setVisibility(View.GONE); | 
 |  |  |                 getDB().btSk.setVisibility(View.GONE); | 
 |  |  |  | 
 |  |  |                 getDB().clSjSk.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().clSjRl.setVisibility(View.GONE); | 
 |  |  |                 getDB().clTip1.setVisibility(View.GONE); | 
 |  |  |                 getDB().clFace.setVisibility(View.GONE); | 
 |  |  |                 getDB().clCard.setVisibility(View.VISIBLE); | 
 |  |  |                 setFaceModel(2); | 
 |  |  |                 break; | 
 |  |  |             default: | 
 |  |  |                 break; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void setFaceModel(int faceModel){ | 
 |  |  |         if(faceModel==0){ | 
 |  |  |             //管理员 | 
 |  |  |             FaceSDKManager.getInstance().setGroupId("0"); | 
 |  |  |             isToChose = false; | 
 |  |  |         }else if(faceModel==1){ | 
 |  |  |             //司机 | 
 |  |  |             FaceSDKManager.getInstance().setGroupId("1"); | 
 |  |  |             isToChose = false; | 
 |  |  |         }else { | 
 |  |  |             isToChose = true; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         switch (type){ | 
 |  |  |             case 1: | 
 |  |  |                 //切换到刷卡 | 
 |  |  |                 if("0".equals(flag)){ | 
 |  |  |                 if(flag==0){ | 
 |  |  |                     if(status==0){ | 
 |  |  |                         statusFsm(1); | 
 |  |  |                     }else if(status==2){ | 
 |  |  | 
 |  |  |                 break; | 
 |  |  |             case 4: | 
 |  |  |                 //切换到人脸 | 
 |  |  |                 if("0".equals(flag)){ | 
 |  |  |                 if(flag==0){ | 
 |  |  |                     if(status==1){ | 
 |  |  |                         statusFsm(5); | 
 |  |  |                         statusFsm(0); | 
 |  |  |                     }else if(status==3){ | 
 |  |  |                         statusFsm(6); | 
 |  |  |                         statusFsm(2); | 
 |  |  |                     } | 
 |  |  |                 }else { | 
 |  |  |                     startActivity(KeyCabinetActivity.class); | 
 |  |  |                     finish(); | 
 |  |  |                     statusFsm(7); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //todo wmf | 
 |  |  |                 //statusFsm("0".equals(flag)?); | 
 |  |  |                 break; | 
 |  |  |             case 5: | 
 |  |  |                 startActivity(KeyCabinetActivity.class); | 
 |  |  |                 finish(); | 
 |  |  |                 statusFsm(4); | 
 |  |  |                 break; | 
 |  |  |             default: | 
 |  |  |                 break; | 
 |  |  | 
 |  |  |                 SingleBaseConfig.getBaseConfig().getMirrorVideoRGB() , SingleBaseConfig.getBaseConfig().isOpenGl()); | 
 |  |  |         CameraPreviewManager.getInstance().startPreview(glMantleSurfacView, | 
 |  |  |                 SingleBaseConfig.getBaseConfig().getRgbVideoDirection() , PREFER_WIDTH, PERFER_HEIGH); | 
 |  |  |         getDB().tvJg2.setText(getErrPhoneText(), TextView.BufferType.SPANNABLE); | 
 |  |  |  | 
 |  |  |         //ic卡读取 | 
 |  |  |         getDB().etEwm.requestFocus(); | 
 |  |  |         getDB().etEwm.setShowSoftInputOnFocus(false); | 
 |  |  |         hideSoftKeyboard(getDB().etEwm); | 
 |  |  |         getDB().etEwm.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { | 
 |  |  |             @Override | 
 |  |  |             public void onGlobalLayout() { | 
 |  |  |                 hideSoftKeyboard(getDB().etEwm); | 
 |  |  |             } | 
 |  |  |         }); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void hideSoftKeyboard(View view) { | 
 |  |  |         InputMethodManager imm = (InputMethodManager) | 
 |  |  |                 getSystemService(Context.INPUT_METHOD_SERVICE); | 
 |  |  |         if (imm != null) { | 
 |  |  |             imm.hideSoftInputFromWindow(view.getWindowToken(), 0); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     protected void onResume() { | 
 |  |  |         super.onResume(); | 
 |  |  |         //todo wmf 解开 | 
 |  |  |         //startTestOpenDebugRegisterFunction(); | 
 |  |  |         startTestOpenDebugRegisterFunction(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void startTestOpenDebugRegisterFunction() { | 
 |  |  | 
 |  |  |                 handler.sendEmptyMessageDelayed(1,4000); | 
 |  |  |                 glMantleSurfacView.setFrame(); | 
 |  |  |                 bdFaceImageConfig.setData(data); | 
 |  |  |                 //必须会员 | 
 |  |  |                 String groupId = "0"; | 
 |  |  |                 FaceSDKManager.getInstance().onDetectCheck(groupId,bdFaceImageConfig, null, null, | 
 |  |  |                 FaceSDKManager.getInstance().onDetectCheck(bdFaceImageConfig, null, null, | 
 |  |  |                         bdFaceCheckConfig, faceDetectCallBack); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  | 
 |  |  |  | 
 |  |  |         @Override | 
 |  |  |         public void onTip(int code, String msg) { | 
 |  |  |             getDB().clFail.setVisibility(View.VISIBLE); | 
 |  |  |             if(isToChose){ | 
 |  |  |                 return; | 
 |  |  |             } | 
 |  |  |             /*getDB().clFail.setVisibility(View.VISIBLE); | 
 |  |  |             getDB().tv4.setText(msg); | 
 |  |  |             handler.sendEmptyMessageDelayed(0,1000); | 
 |  |  |             handler.sendEmptyMessageDelayed(0,1000);*/ | 
 |  |  |             System.out.println("==isOk==>onTip:"+msg); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         @Override | 
 |  |  |         public void onFaceDetectDarwCallback(LivenessModel livenessModel) { | 
 |  |  |             //System.out.println("==rgbInstance==>onFaceDetectDarwCallback"); | 
 |  |  |             if(isToChose){ | 
 |  |  |                 return; | 
 |  |  |             } | 
 |  |  |             if (isCompareCheck) { | 
 |  |  |                 getDB().clFail.setVisibility(View.VISIBLE); | 
 |  |  |                 /*getDB().clFail.setVisibility(View.VISIBLE); | 
 |  |  |                 getDB().tv4.setText(getString(R.string.face_tip2)); | 
 |  |  |                 handler.sendEmptyMessageDelayed(0,1000); | 
 |  |  |                 handler.sendEmptyMessageDelayed(0,1000);*/ | 
 |  |  |             } | 
 |  |  |             // 绘制人脸框 | 
 |  |  |             showFrame(livenessModel); | 
 |  |  | 
 |  |  |                     break; | 
 |  |  |                 case 1: | 
 |  |  |                     //isCheckFace = false; | 
 |  |  |                     break; | 
 |  |  |                 case 3: | 
 |  |  |                     Toast.makeText(mContext, "酒精检查返回", Toast.LENGTH_SHORT).show(); | 
 |  |  |                     if(new BigDecimal(MApplication.getConfigBean().getCabinetConfigDataVO().getConcentration()) | 
 |  |  |                             .compareTo(resultEvent.getConcentration())>=0){ | 
 |  |  |                         //酒精通过 | 
 |  |  |                         getDB().clJiujinOk.setVisibility(View.VISIBLE); | 
 |  |  |                         handler.sendEmptyMessageDelayed(4,1000); | 
 |  |  |                     }else { | 
 |  |  |                         //酒精不通过 | 
 |  |  |                         getVM().alcoholTestAlarm(""); | 
 |  |  |                         Toast.makeText(mContext, "酒精检测不通过", Toast.LENGTH_SHORT).show(); | 
 |  |  |                         statusFsm(6); | 
 |  |  |                     } | 
 |  |  |                     break; | 
 |  |  |                 case 4: | 
 |  |  |                     startActivity(KeyCabinetActivity.class); | 
 |  |  |                     finish(); | 
 |  |  |                     break; | 
 |  |  |                 default: | 
 |  |  |                     break; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  | 
 |  |  |         handler.removeCallbacksAndMessages(null); | 
 |  |  |         handler = null; | 
 |  |  |         dataCallback = null; | 
 |  |  |         //CameraPreviewManager.getInstance().destroy(); | 
 |  |  |         CameraPreviewManager.getInstance().destroy(); | 
 |  |  |         faceDetectCallBack = null; | 
 |  |  |         glMantleSurfacView = null; | 
 |  |  |         //todo wmf 解开 | 
 |  |  |         //FaceSDKManager.getInstance().destroy(); | 
 |  |  |         FaceSDKManager.getInstance().destroy(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private int resultCount = 0; | 
 |  |  | 
 |  |  |         runOnUiThread(new Runnable() { | 
 |  |  |             @Override | 
 |  |  |             public void run() { | 
 |  |  |                 if(isToChose) { | 
 |  |  |                     return; | 
 |  |  |                 } | 
 |  |  |                 if (livenessModel == null) { | 
 |  |  |                     if (isCompareCheck) { | 
 |  |  |                         getDB().clFail.setVisibility(View.VISIBLE); | 
 |  |  |                         /*getDB().clFail.setVisibility(View.VISIBLE); | 
 |  |  |                         getDB().tv4.setText(getString(R.string.face_tip2)); | 
 |  |  |                         handler.sendEmptyMessageDelayed(0,1000); | 
 |  |  |                         handler.sendEmptyMessageDelayed(0,1000);*/ | 
 |  |  |                     } | 
 |  |  |                     System.out.println("======>人脸识别失败"); | 
 |  |  |                     return; | 
 |  |  | 
 |  |  |                 if (livenessModel.isQualityCheck()){ | 
 |  |  |                     //是否通过质量检测 | 
 |  |  |                     if (isCompareCheck) { | 
 |  |  |                         getDB().clFail.setVisibility(View.VISIBLE); | 
 |  |  |                         /*getDB().clFail.setVisibility(View.VISIBLE); | 
 |  |  |                         getDB().tv4.setText(getString(R.string.face_tip2)); | 
 |  |  |                         handler.sendEmptyMessageDelayed(0,1000); | 
 |  |  |                         handler.sendEmptyMessageDelayed(0,1000);*/ | 
 |  |  |                     } | 
 |  |  |                 } else { | 
 |  |  |                     User user = livenessModel.getUser(); | 
 |  |  |                     if (user == null) { | 
 |  |  |                         mUser = null; | 
 |  |  |                         if (isCompareCheck) { | 
 |  |  |                             getDB().clFail.setVisibility(View.VISIBLE); | 
 |  |  |                             /*getDB().clFail.setVisibility(View.VISIBLE); | 
 |  |  |                             getDB().tv4.setText(getString(R.string.face_tip2)); | 
 |  |  |                             handler.sendEmptyMessageDelayed(0,1000); | 
 |  |  |                             handler.sendEmptyMessageDelayed(0,1000);*/ | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                     } else { | 
 |  |  |                         //优先会员 | 
 |  |  |                         if("0".equals(user.getGroupId())){ | 
 |  |  | 11 | 
 |  |  |                         }else { | 
 |  |  |                             if (isCompareCheck) { | 
 |  |  |                                 getDB().clFail.setVisibility(View.VISIBLE); | 
 |  |  |                                 getDB().tv4.setText(getString(R.string.face_tip2)); | 
 |  |  |                                 handler.sendEmptyMessageDelayed(0,1000); | 
 |  |  |                             } | 
 |  |  |                             resultCount++; | 
 |  |  |                             if (resultCount >= 3) { | 
 |  |  |                                 resultCount = 0; | 
 |  |  |                             }else { | 
 |  |  |                                 return; | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                         mUser = user; | 
 |  |  |                         if (isCompareCheck) { | 
 |  |  |                             getDB().clFail.setVisibility(View.GONE); | 
 |  |  | 
 |  |  |                             nameText.setTextColor(Color.parseColor("#0dc6ff")); | 
 |  |  |                             nameText.setText(FileUtils.spotString(user.getUserName()) + " 欢迎您");*/ | 
 |  |  |                         } | 
 |  |  |                         if(!isToChose) { | 
 |  |  |                             isToChose = true; | 
 |  |  |                             //识别成功,跳转 | 
 |  |  |                             Bundle bundle = new Bundle(); | 
 |  |  |                             bundle.putString("busId", user.getUserId()); | 
 |  |  |                             bundle.putString("type", "0"); | 
 |  |  |                             //Toast.makeText(mContext, user.getUserName(), Toast.LENGTH_SHORT).show(); | 
 |  |  |                             //startActivity(ChoseTicketActivity.class, bundle); | 
 |  |  |                         isToChose = true; | 
 |  |  |                         //识别成功,跳转 | 
 |  |  |                         if(status==0){ | 
 |  |  |                             //取-管理员 | 
 |  |  |                             MApplication.getLoginBean().setAutoMemberId(Integer.parseInt(user.getUserId())); | 
 |  |  |                             //handler.sendEmptyMessageDelayed(7,0); | 
 |  |  |                             EventBus.getDefault().post(new FaceStatusChangeEvent(5)); | 
 |  |  |                         }else if(status==2){ | 
 |  |  |                             //取-司机 | 
 |  |  |                             CameraPreviewManager.getInstance().stopPreview(); | 
 |  |  |                             MApplication.getLoginBean().setMemberId(Integer.parseInt(user.getUserId())); | 
 |  |  |                             MApplication.getLoginBean().setAuthType(0); | 
 |  |  |                             //handler.sendEmptyMessageDelayed(8,0); | 
 |  |  |                             EventBus.getDefault().post(new FaceStatusChangeEvent(4)); | 
 |  |  |                         }else if(status==7){ | 
 |  |  |                             //还-司机 | 
 |  |  |                             MApplication.getLoginBean().setMemberId(Integer.parseInt(user.getUserId())); | 
 |  |  |                             MApplication.getLoginBean().setAuthType(0); | 
 |  |  |                             startActivity(KeyCabinetActivity.class); | 
 |  |  |                             finish(); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         }); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Subscribe(threadMode = ThreadMode.MAIN) | 
 |  |  |     public void FaceStatusChangeEvent(FaceStatusChangeEvent e){ | 
 |  |  |         if(!isFinishing()){ | 
 |  |  |             statusFsm(e.getStatus()); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     boolean isToChose = false; | 
 |  |  | 
 |  |  |         super.onPause(); | 
 |  |  |         isPause = false; | 
 |  |  |         isTimePause = true; | 
 |  |  |         //todo wmf 解开 | 
 |  |  |         //CameraPreviewManager.getInstance().stopPreview(); | 
 |  |  |         CameraPreviewManager.getInstance().stopPreview(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private JiujinResultEvent resultEvent; | 
 |  |  |     @Subscribe(threadMode = ThreadMode.MAIN) | 
 |  |  |     public void JiujinResultEvent(JiujinResultEvent e){ | 
 |  |  |         if(!isFinishing()){ | 
 |  |  |             //Toast.makeText(mContext, "酒精检测返回:"+e.isOk(), Toast.LENGTH_SHORT).show(); | 
 |  |  |             if(!e.isOk()){ | 
 |  |  |                 statusFsm(6); | 
 |  |  |             }else { | 
 |  |  |                 if(resultEvent==null){ | 
 |  |  |                     resultEvent = e; | 
 |  |  |                 }else if(resultEvent.getConcentration().compareTo(e.getConcentration())<0){ | 
 |  |  |                     //值更大 | 
 |  |  |                     resultEvent = e; | 
 |  |  |                 } | 
 |  |  |                 if(handler.hasMessages(3)){ | 
 |  |  |                     handler.removeMessages(3); | 
 |  |  |                 } | 
 |  |  |                 handler.sendEmptyMessageDelayed(3,1000); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | } |