Commit 9e2af6b9 by pye52

Merge branch 'develop'

parents e79b5e85 6b3ab98a
...@@ -6,6 +6,7 @@ import androidx.annotation.NonNull; ...@@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
import androidx.work.Configuration; import androidx.work.Configuration;
import com.bgycc.smartcanteen.executor.SCTaskExecutor; import com.bgycc.smartcanteen.executor.SCTaskExecutor;
import com.bgycc.smartcanteen.utils.NetworkUtils;
import com.blankj.utilcode.util.CrashUtils; import com.blankj.utilcode.util.CrashUtils;
import com.blankj.utilcode.util.LogUtils; import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.PathUtils; import com.blankj.utilcode.util.PathUtils;
...@@ -31,6 +32,7 @@ public class RootApp extends Application implements Configuration.Provider { ...@@ -31,6 +32,7 @@ public class RootApp extends Application implements Configuration.Provider {
.setBorderSwitch(false) .setBorderSwitch(false)
.setFilePrefix(LOG_PREFIX) .setFilePrefix(LOG_PREFIX)
.setSaveDays(LOG_SAVE_DAYS); .setSaveDays(LOG_SAVE_DAYS);
NetworkUtils.initialize(this);
} }
@NonNull @NonNull
......
...@@ -97,7 +97,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -97,7 +97,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
deviceSN = SmartCanteenUtils.getDeviceSN(newBase.getApplicationContext()); deviceSN = SmartCanteenUtils.getDeviceSN(newBase.getApplicationContext());
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
TTSHelper.initialize(newBase.getApplicationContext()); TTSHelper.initialize(newBase.getApplicationContext());
NetworkUtils.initialize(newBase.getApplicationContext());
if (deviceSN.isEmpty()) { if (deviceSN.isEmpty()) {
LogUtils.file(TAG, "设备SN号为空"); LogUtils.file(TAG, "设备SN号为空");
......
...@@ -19,10 +19,10 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG; ...@@ -19,10 +19,10 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
public class TTSHelper { public class TTSHelper {
private static boolean mSupportTTS = false; private static boolean mSupportTTS = false;
private static TextToSpeech mTTS = null; private static TextToSpeech mTTS = null;
private static final SoundPool mSoundPool; private static SoundPool mSoundPool;
private static final HashMap<String, Integer> mSoundIdMap = new HashMap<>(); private static final HashMap<String, Integer> mSoundIdMap = new HashMap<>();
static { public static void initialize(Context context) {
AudioAttributes audioAttributes = new AudioAttributes.Builder() AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_NOTIFICATION) .setUsage(AudioAttributes.USAGE_NOTIFICATION)
.setContentType(AudioAttributes.CONTENT_TYPE_SPEECH) .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
...@@ -31,9 +31,6 @@ public class TTSHelper { ...@@ -31,9 +31,6 @@ public class TTSHelper {
mSoundPool = new SoundPool.Builder() mSoundPool = new SoundPool.Builder()
.setAudioAttributes(audioAttributes) .setAudioAttributes(audioAttributes)
.build(); .build();
}
public static void initialize(Context context) {
mSoundPool.setOnLoadCompleteListener((soundPool, sampleId, status) -> { mSoundPool.setOnLoadCompleteListener((soundPool, sampleId, status) -> {
if (status == 0) { if (status == 0) {
soundPool.play(sampleId, 1f, 1f, 100, 0, 1f); soundPool.play(sampleId, 1f, 1f, 100, 0, 1f);
...@@ -45,6 +42,7 @@ public class TTSHelper { ...@@ -45,6 +42,7 @@ public class TTSHelper {
mSupportTTS = result >= TextToSpeech.LANG_AVAILABLE; mSupportTTS = result >= TextToSpeech.LANG_AVAILABLE;
} }
}); });
mSoundIdMap.clear();
} }
public static void speak(String msg) { public static void speak(String msg) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment