weimingfei
昨天 338e7ed513d21d1468c0908fdca2ea4097ee0621
keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/face/FaceActivity.java
@@ -45,6 +45,7 @@
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.api.FaceApi;
import com.example.datalibrary.callback.CameraDataCallback;
import com.example.datalibrary.callback.FaceDetectCallBack;
import com.example.datalibrary.db.DBManager;
@@ -63,6 +64,8 @@
import org.greenrobot.eventbus.ThreadMode;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import dagger.hilt.android.AndroidEntryPoint;
@@ -536,10 +539,24 @@
            //System.out.println("==rgbInstance==>onFaceDetectCallback   "+livenessModel);
            // 开发模式
            //isCheckFace = false;
            try {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if(handler==null){
                            return;
                        }
            if(handler.hasMessages(1)){
                handler.removeMessages(1);
            }
            checkOpenDebugResult(livenessModel);
                    }
                });
            }catch (Exception e){
                e.printStackTrace();
                ToastView.show(MApplication.mContext,"人脸报错2:"+e.getMessage());
            }
        }
        @Override
@@ -550,7 +567,7 @@
            /*getDB().clFail.setVisibility(View.VISIBLE);
            getDB().tv4.setText(msg);
            handler.sendEmptyMessageDelayed(0,1000);*/
            System.out.println("==isOk==>onTip:"+msg);
            //System.out.println("==isOk==>onTip:"+msg);
        }
        @Override
@@ -578,11 +595,15 @@
        if (livenessModel == null){
            return;
        }
        try {
        if (isPause){
            glMantleSurfacView.onGlDraw(livenessModel.getTrackFaceInfo() ,
                    livenessModel.getBdFaceImageInstance() ,
                    FaceOnDrawTexturViewUtil.drawFaceColor(mUser , livenessModel));
            }
        }catch (Exception e){
            e.printStackTrace();
            ToastView.show(MApplication.mContext,"人脸报错1:"+e.getMessage());
        }
    }
@@ -633,6 +654,9 @@
                case 6:
                    getDB().message.setVisibility(View.GONE);
                    break;
                case 7:
                    identify();
                    break;
                default:
                    break;
            }
@@ -681,6 +705,7 @@
    private int resultCount = 0;
    // ***************开发模式结果输出*************
    private void checkOpenDebugResult(final LivenessModel livenessModel) {
        try {
        if(isFinishing()){
            return;
        }
@@ -688,9 +713,6 @@
            return;
        }
        // 当未检测到人脸UI显示
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if(isToChose) {
                    return;
                }
@@ -700,7 +722,7 @@
                        getDB().tv4.setText(getString(R.string.face_tip2));
                        handler.sendEmptyMessageDelayed(0,1000);*/
                    }
                    System.out.println("======>人脸识别失败");
                //System.out.println("======>人脸识别失败");
                    return;
                }
                if (livenessModel.isQualityCheck()){
@@ -767,8 +789,10 @@
                        }
                    }
                }
        }catch (Exception e){
            e.printStackTrace();
            ToastView.show(MApplication.mContext,"人脸报错:"+e.getMessage());
            }
        });
    }
    @Subscribe(threadMode = ThreadMode.MAIN)
@@ -828,14 +852,31 @@
            public void run() {
                FingerPrintDo printDo = DaoManager.getFingerPrintDao().getByFingerId(fingerId);
                if(printDo!=null){
                    List<User> users = FaceApi.getInstance().getAllUserList();
                    HashMap<String,String> map = new HashMap<>();
                    for(User u:users){
                        if(u.getUserId().equals(printDo.getMemberId()+"")){
                            map.put(u.getGroupId(),"");
                        }
                    }
                    if(status==10){
                        //取-管理员指纹验证
                        if(!map.containsKey("0")){
                            showToast("您当前不是管理员");
                            handler.sendEmptyMessageDelayed(7,2000);
                            return;
                        }
                        MApplication.getLoginBean().setAutoMemberId(printDo.getMemberId());
                        EventBus.getDefault().post(new FaceStatusChangeEvent(5));
                    }else if(status==11){
                        //取-司机指纹验证
                        if(!map.containsKey("1")){
                            showToast("您当前不是司机");
                            handler.sendEmptyMessageDelayed(7,2000);
                            return;
                        }
                        MApplication.getLoginBean().setMemberId(printDo.getMemberId());
                        MApplication.getLoginBean().setAuthType(2);
                        MApplication.getLoginBean().setAuthType(3);
                        if(MApplication.getConfigBean()!=null&&MApplication.getConfigBean().getAlcoholStatus()==1) {
                            //非酒精检测
                            startActivity(KeyCabinetActivity.class);
@@ -846,8 +887,13 @@
                        }
                    }else if(status==12){
                        //还-司机
                        if(!map.containsKey("1")){
                            showToast("您当前不是司机");
                            handler.sendEmptyMessageDelayed(7,2000);
                            return;
                        }
                        MApplication.getLoginBean().setMemberId(printDo.getMemberId());
                        MApplication.getLoginBean().setAuthType(2);
                        MApplication.getLoginBean().setAuthType(3);
                        startActivity(KeyCabinetActivity.class);
                        finish();
                    }
@@ -855,7 +901,7 @@
                    //找不到,删除指纹
                    if(deleteID(fingerId)) {
                        //继续查指纹
                        identify();
                        handler.sendEmptyMessageDelayed(7,2000);
                    }else {
                        showToast("未查询到用户");
                    }
@@ -933,7 +979,6 @@
    private void identify() {
        if (!mDevComm.IsInit())
            return;
        mBCancel = false;
        new Thread(new Runnable() {
            int w_nRet;
@@ -991,7 +1036,7 @@
                        //m_strPost = String.format("Result : Success\r\nTemplate No : %d, Learn Result : %d\r\nMatch Time : %dms", w_nID[0], w_nLearned[0], m_nPassedTime);
                    } else {
                        //没找到
                        //showToast("没找到");
                        showToast("未检测到该指纹");
                        /*m_strPost = String.format("\r\nMatch Time : %dms", m_nPassedTime);
                        m_strPost = GetErrorMsg(w_nRet) + m_strPost;*/
                    }
@@ -1045,7 +1090,7 @@
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
                    ToastView.show(MApplication.mContext,msg);
                }
            });
        }