فهرست منبع

<修改判断tts开启方法>

weizhengliang 4 سال پیش
والد
کامیت
0e9a16f325
1فایلهای تغییر یافته به همراه26 افزوده شده و 20 حذف شده
  1. 26 20
      app/src/main/java/com/wdkl/callingmainnurse/ui/fragment/CallingBedFragment.java

+ 26 - 20
app/src/main/java/com/wdkl/callingmainnurse/ui/fragment/CallingBedFragment.java

@@ -428,7 +428,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
     public static CallingBedFragment mCallingBedFragment;
 
     //是否开启TTS语音播报
-    private boolean enableTTS = (Constants.TTS_STATUS == 2 && SharedPreferencesUtil.getIntSp(MyApplication.getAppContext(), Constants.MSG_SP, SharedPreferencesUtil.TtsOn)==1);
+    //private boolean enableTTS = false;
 
     private CallATimeoutThread callATimeoutThread;
     private List<CallListEntity> callListEntityList;
@@ -522,7 +522,8 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
         serialPortUtil.setOnDataReceiveListener(this, this);
         setVolumePA(false);
         setPowerLed("1");
-        if (enableTTS) {
+
+        if (enableTTS()) {
             SpeechUtil.getInstance().startSpeechThread();
         } else {
             startPalyPhonetics();
@@ -650,6 +651,10 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
         rvImportantMessage.setAdapter(importantMessageAdapter);
     }
 
+    private boolean enableTTS() {
+        return Constants.TTS_STATUS == 2 && SharedPreferencesUtil.getIntSp(MyApplication.getAppContext(), Constants.MSG_SP, SharedPreferencesUtil.TtsOn)==1;
+    }
+
     /**
      * 删除指定的条目(change by waderson 20191108)
      * @param deleteEntity 被删除的实体
@@ -674,7 +679,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
             }
         }
 
-        if (enableTTS) {
+        if (enableTTS()) {
             SpeechUtil.getInstance().stopSpeak();
         }
 
@@ -726,7 +731,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
             }
         }
 
-        if (enableTTS) {
+        if (enableTTS()) {
             SpeechUtil.getInstance().stopSpeak();
         }
 
@@ -1030,7 +1035,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                 if (null != loopVoice) {
                     loopVoice.setPalyDismiss(true);
                 }
-                if (enableTTS) {
+                if (enableTTS()) {
                     SpeechUtil.getInstance().stopSpeak();
                 }
                 //String sipAddress = callingEntity.getSipAddress();
@@ -1052,7 +1057,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                         loopVoice.setPalyDismiss(true);
                     }
                 }
-                if (enableTTS) {
+                if (enableTTS()) {
                     SpeechUtil.getInstance().stopSpeak();
                 }
                 endCall();
@@ -1082,7 +1087,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                     if (null != loopVoice) {
                         loopVoice.setPalyDismiss(true);
                     }
-                    if (enableTTS) {
+                    if (enableTTS()) {
                         SpeechUtil.getInstance().stopSpeak();
                     }
                     if (StringUtils.notEmpty(sipAddress)) {
@@ -1196,7 +1201,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
         if (vRightCallInfo.getVisibility() == View.VISIBLE && sickBedInfo.equals(sickbedInformationList.get(position))) {
             if (null == sickBedInfo || !StringUtils.listNotEmpty(sickbedInformationList)) return;
             if (filterSipToast()) {
-                if (enableTTS) {
+                if (enableTTS()) {
                     SpeechUtil.getInstance().stopSpeak();
                 }
                 if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
@@ -1286,7 +1291,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
         if (vRightCallListInfo.getVisibility() == View.VISIBLE && callItemChooseEntity != null && callItemChooseEntity.equals(MyApplication.callEntityList.get(position))) {
             //if (null == callItemChooseEntity) return;
             if (filterSipToast() && !MyApplication.callEntityList.get(position).getType().equals(Constants.WSHROOM_CALL) && !MyApplication.callEntityList.get(position).getType().equals(Constants.ROOMHELP_CALL)) {
-                if (enableTTS) {
+                if (enableTTS()) {
                     SpeechUtil.getInstance().stopSpeak();
                 }
                 if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
@@ -1371,7 +1376,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                                         if (null != loopVoice) {
                                             loopVoice.setPalyDismiss(true);
                                         }
-                                        if (enableTTS) {
+                                        if (enableTTS()) {
                                             SpeechUtil.getInstance().stopSpeak();
                                         }
                                     } else {
@@ -1445,7 +1450,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                         loopVoice.setVolumes(0f);
                         loopVoice.setPalyDismiss(true);
                     }
-                    if (enableTTS) {
+                    if (enableTTS()) {
                         SpeechUtil.getInstance().stopSpeak();
                     }
                     //安卓端接通电话,通知点阵屏,但要排除固定列表
@@ -1499,7 +1504,8 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                     case "call_4"://增援呼叫护士主机
                     case "call_6": //门口机呼叫护士主机
                         if (isMySelfMachine(nurseHostID)) {//只有属于自己管的机器才能加进列表
-                            if (enableTTS) {
+                            LogUtil.d("speech", "enableTTS: " + enableTTS());
+                            if (enableTTS()) {
                                 //使用TTS播报
                                 if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
                                     startSpeak(udpEntity);
@@ -1532,7 +1538,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                         break;
                     case "call_12": //总控制室呼叫护士主机
                         if (isMySelfMachine(nurseHostID)) {
-                            if (enableTTS) {
+                            if (enableTTS()) {
                                 //使用TTS播报
                                 if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
                                     startSpeak(udpEntity);
@@ -1558,7 +1564,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                     case "call_14": //医生主机呼叫护士主机
                         Log.e("qqqq","nurseHostID "+nurseHostID);
                         if (isMySelfMachine(nurseHostID)) {
-                            if (enableTTS) {
+                            if (enableTTS()) {
                                 //使用TTS播报
                                 if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
                                     startSpeak(udpEntity);
@@ -1710,7 +1716,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                 if (null != loopVoice) {
                     loopVoice.setPalyDismiss(true);
                 }
-                if (enableTTS) {
+                if (enableTTS()) {
                     SpeechUtil.getInstance().stopSpeak();
                 }
             } else {
@@ -1793,7 +1799,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                 //if (null != loopVoice) {
                 //    loopVoice.setPalyDismiss(true);
                 //}
-                if (enableTTS) {
+                if (enableTTS()) {
                     SpeechUtil.getInstance().stopSpeak();
                 }
                 for (int i = 0; i < PalyPhonetics.speakEntityList.size(); i++) {
@@ -1956,7 +1962,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                         if (null != loopVoice) {
                             loopVoice.setPalyDismiss(true);
                         }
-                        if (enableTTS) {
+                        if (enableTTS()) {
                             SpeechUtil.getInstance().stopSpeak();
                         }
                     } else {
@@ -1993,7 +1999,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                         if (null != loopVoice) {
                             loopVoice.setPalyDismiss(true);
                         }
-                        if (enableTTS) {
+                        if (enableTTS()) {
                             SpeechUtil.getInstance().stopSpeak();
                         }
                     } else {
@@ -2386,7 +2392,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                                             loopVoice.setPalyDismiss(true);
                                         }
                                     }
-                                    if (enableTTS) {
+                                    if (enableTTS()) {
                                         SpeechUtil.getInstance().stopSpeak();
                                     }
                                     endCall(); //否则就挂断电话!
@@ -2412,7 +2418,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                                     loopVoice.setPalyDismiss(true);
                                 }
                             }
-                            if (enableTTS) {
+                            if (enableTTS()) {
                                 SpeechUtil.getInstance().stopSpeak();
                             }
                             endCall(); //挂断电话!