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

This commit is contained in:
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" applicationId "com.navinfo.outdoor"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 30 targetSdkVersion 30
versionCode 35 versionCode 36
versionName "8.221206" versionName "8.221207"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
lintOptions { lintOptions {

View File

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

View File

@@ -3,8 +3,8 @@ package com.navinfo.outdoor.http;
public class HttpInterface { public class HttpInterface {
// public static final String IP = "http://172.23.138.133:9999/m4";//测试接口-IP // 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 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/test/m4";//测试接口-外网
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口 public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
public static final String USER_PATH = "/user/";//我的 public static final String USER_PATH = "/user/";//我的
public static final String MSG_LIST_PATH = "/msgList/";//发现 public static final String MSG_LIST_PATH = "/msgList/";//发现
public static final String USER_LOGIN_PATH = "/userlogin/";//登录 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.speech.tts.UtteranceProgressListener;
import android.widget.Toast; import android.widget.Toast;
import com.elvishew.xlog.XLog;
import com.github.lazylibrary.util.ToastUtils;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Set; import java.util.Set;
@SuppressLint("NewApi")
public class SystemTTS extends UtteranceProgressListener implements TTS, TextToSpeech.OnUtteranceCompletedListener { public class SystemTTS extends UtteranceProgressListener implements TTS, TextToSpeech.OnUtteranceCompletedListener {
private Context mContext; private Context mContext;
private static SystemTTS singleton; private static SystemTTS singleton;
@@ -33,11 +35,11 @@ public class SystemTTS extends UtteranceProgressListener implements TTS, TextToS
textToSpeech = new TextToSpeech(mContext, new TextToSpeech.OnInitListener() { textToSpeech = new TextToSpeech(mContext, new TextToSpeech.OnInitListener() {
@Override @Override
public void onInit(int i) { public void onInit(int i) {
if (i == TextToSpeech.SUCCESS) {
}
});
//系统语音初始化成功 //系统语音初始化成功
XLog.v("tts初始化成功");
int result = textToSpeech.setLanguage(Locale.getDefault()); int result = textToSpeech.setLanguage(Locale.getDefault());
XLog.v("tts设置Language结果"+result);
textToSpeech.setPitch(1.0f);// 设置音调,值越大声音越尖(女生),值越小则变成男声,1.0是常规 textToSpeech.setPitch(1.0f);// 设置音调,值越大声音越尖(女生),值越小则变成男声,1.0是常规
textToSpeech.setSpeechRate(1.0f); textToSpeech.setSpeechRate(1.0f);
textToSpeech.setOnUtteranceProgressListener(SystemTTS.this); textToSpeech.setOnUtteranceProgressListener(SystemTTS.this);
@@ -45,11 +47,20 @@ public class SystemTTS extends UtteranceProgressListener implements TTS, TextToS
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
//系统不支持中文播报 //系统不支持中文播报
isSuccess = false; isSuccess = false;
ToastUtils.showToast(context, "系统不支持中文播报!");
} }
} else {
XLog.v("tts初始化结果"+i);
ToastUtils.showToast(context, "tts初始化失败");
}
}
});
} }
public void playText(String playText) { public void playText(String playText) {
// if (!isSuccess) { // if (!isSuccess) {
// ToastUtils.showToast(this.mContext, playText);
// return; // return;
// } // }
Set<Locale> availableLanguages = textToSpeech.getAvailableLanguages(); Set<Locale> availableLanguages = textToSpeech.getAvailableLanguages();

View File

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