fix: 修改语音提示某些时候初始化失败的问题

This commit is contained in:
xiaoyan 2022-12-07 16:56:36 +08:00
parent 559fe05db2
commit 2f5c8464b6
5 changed files with 42 additions and 24 deletions

View File

@ -12,8 +12,8 @@ android {
applicationId "com.navinfo.outdoor"
minSdkVersion 23
targetSdkVersion 30
versionCode 35
versionName "8.221206"
versionCode 36
versionName "8.221207"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {

View File

@ -704,11 +704,12 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
@Override
public void onNext(PoiEntity poiEntity) {
write2Log("领取任务成功:", poiEntity.getId());
}
@Override
public void onError(Throwable e) {
systemTTS.playText("注意,领取任务失败!");
if (AutoTakePictureActivity.this!=null) {
write2Log("领取任务失败:", e.getMessage()+",网络状态-:"+ NetWorkUtils.getNetworkTypeName(AutoTakePictureActivity.this));
}
@ -765,7 +766,13 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
})
// 判断筛选出的数据是否已经在匹配列表中如果不存在需要自动领取该任务记录开始采集时间
.filter(
o -> roadMatchEntityList.stream().noneMatch(roadMatchEntity -> o.getId()==roadMatchEntity.getId()))
o -> {
if (roadMatchEntityList.stream().noneMatch(roadMatchEntity -> o.getId()==roadMatchEntity.getId())) {
return true; // 如果列表中不存在当前数据不过滤断点使用增加return
} else {
return false;
}
})
.collect(Collectors.toList());
if (matchStartList!=null&&!matchStartList.isEmpty()) {
// 存在新匹配到的数据

View File

@ -3,8 +3,8 @@ package com.navinfo.outdoor.http;
public class HttpInterface {
// public static final String IP = "http://172.23.138.133:9999/m4";//测试接口-IP
public static final String IPm = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发接口-外网
public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网
public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
public static final String USER_PATH = "/user/";//我的
public static final String MSG_LIST_PATH = "/msgList/";//发现
public static final String USER_LOGIN_PATH = "/userlogin/";//登录

View File

@ -6,11 +6,13 @@ import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener;
import android.widget.Toast;
import com.elvishew.xlog.XLog;
import com.github.lazylibrary.util.ToastUtils;
import java.util.List;
import java.util.Locale;
import java.util.Set;
@SuppressLint("NewApi")
public class SystemTTS extends UtteranceProgressListener implements TTS, TextToSpeech.OnUtteranceCompletedListener {
private Context mContext;
private static SystemTTS singleton;
@ -33,23 +35,32 @@ public class SystemTTS extends UtteranceProgressListener implements TTS, TextToS
textToSpeech = new TextToSpeech(mContext, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int i) {
if (i == TextToSpeech.SUCCESS) {
//系统语音初始化成功
XLog.v("tts初始化成功");
int result = textToSpeech.setLanguage(Locale.getDefault());
XLog.v("tts设置Language结果"+result);
textToSpeech.setPitch(1.0f);// 设置音调值越大声音越尖女生值越小则变成男声,1.0是常规
textToSpeech.setSpeechRate(1.0f);
textToSpeech.setOnUtteranceProgressListener(SystemTTS.this);
textToSpeech.setOnUtteranceCompletedListener(SystemTTS.this);
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
//系统不支持中文播报
isSuccess = false;
ToastUtils.showToast(context, "系统不支持中文播报!");
}
} else {
XLog.v("tts初始化结果"+i);
ToastUtils.showToast(context, "tts初始化失败");
}
}
});
//系统语音初始化成功
int result = textToSpeech.setLanguage(Locale.getDefault());
textToSpeech.setPitch(1.0f);// 设置音调值越大声音越尖女生值越小则变成男声,1.0是常规
textToSpeech.setSpeechRate(1.0f);
textToSpeech.setOnUtteranceProgressListener(SystemTTS.this);
textToSpeech.setOnUtteranceCompletedListener(SystemTTS.this);
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
//系统不支持中文播报
isSuccess = false;
}
}
public void playText(String playText) {
// if (!isSuccess) {
// ToastUtils.showToast(this.mContext, playText);
// return;
// }
Set<Locale> availableLanguages = textToSpeech.getAvailableLanguages();

View File

@ -4,9 +4,6 @@ buildscript {
ext.kotlin_version = '1.5.10'
repositories {
maven { url "https://jitpack.io" }
maven{
url "https://maven.google.com/"
}
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
// bug
maven { url 'https://repo1.maven.org/maven2/' }
@ -17,6 +14,9 @@ buildscript {
jcenter()
mavenCentral()
google()
maven{
url "https://maven.google.com/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
@ -31,9 +31,6 @@ buildscript {
allprojects {
repositories {
maven { url "https://jitpack.io" }
maven{
url "https://maven.google.com/"
}
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
// bug
maven { url 'https://repo1.maven.org/maven2/' }
@ -44,6 +41,9 @@ allprojects {
jcenter()
mavenCentral()
google()
maven{
url "https://maven.google.com/"
}
}
}