Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6b3ab98a
authored
Jun 01, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、优化退到后台再回到主界面会无声的问题
2、保证NetworkUtils只初始化一次
parent
d5045697
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
6 deletions
+5
-6
app/src/main/java/com/bgycc/smartcanteen/RootApp.java
+2
-0
app/src/main/java/com/bgycc/smartcanteen/activity/MainActivity.java
+0
-1
app/src/main/java/com/bgycc/smartcanteen/utils/TTSHelper.java
+3
-5
No files found.
app/src/main/java/com/bgycc/smartcanteen/RootApp.java
View file @
6b3ab98a
...
...
@@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
import
androidx.work.Configuration
;
import
com.bgycc.smartcanteen.executor.SCTaskExecutor
;
import
com.bgycc.smartcanteen.utils.NetworkUtils
;
import
com.blankj.utilcode.util.CrashUtils
;
import
com.blankj.utilcode.util.LogUtils
;
import
com.blankj.utilcode.util.PathUtils
;
...
...
@@ -31,6 +32,7 @@ public class RootApp extends Application implements Configuration.Provider {
.
setBorderSwitch
(
false
)
.
setFilePrefix
(
LOG_PREFIX
)
.
setSaveDays
(
LOG_SAVE_DAYS
);
NetworkUtils
.
initialize
(
this
);
}
@NonNull
...
...
app/src/main/java/com/bgycc/smartcanteen/activity/MainActivity.java
View file @
6b3ab98a
...
...
@@ -97,7 +97,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
deviceSN
=
SmartCanteenUtils
.
getDeviceSN
(
newBase
.
getApplicationContext
());
audioManager
=
(
AudioManager
)
getSystemService
(
Context
.
AUDIO_SERVICE
);
TTSHelper
.
initialize
(
newBase
.
getApplicationContext
());
NetworkUtils
.
initialize
(
newBase
.
getApplicationContext
());
if
(
deviceSN
.
isEmpty
())
{
LogUtils
.
file
(
TAG
,
"设备SN号为空"
);
...
...
app/src/main/java/com/bgycc/smartcanteen/utils/TTSHelper.java
View file @
6b3ab98a
...
...
@@ -19,10 +19,10 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
public
class
TTSHelper
{
private
static
boolean
mSupportTTS
=
false
;
private
static
TextToSpeech
mTTS
=
null
;
private
static
final
SoundPool
mSoundPool
;
private
static
SoundPool
mSoundPool
;
private
static
final
HashMap
<
String
,
Integer
>
mSoundIdMap
=
new
HashMap
<>();
static
{
public
static
void
initialize
(
Context
context
)
{
AudioAttributes
audioAttributes
=
new
AudioAttributes
.
Builder
()
.
setUsage
(
AudioAttributes
.
USAGE_NOTIFICATION
)
.
setContentType
(
AudioAttributes
.
CONTENT_TYPE_SPEECH
)
...
...
@@ -31,9 +31,6 @@ public class TTSHelper {
mSoundPool
=
new
SoundPool
.
Builder
()
.
setAudioAttributes
(
audioAttributes
)
.
build
();
}
public
static
void
initialize
(
Context
context
)
{
mSoundPool
.
setOnLoadCompleteListener
((
soundPool
,
sampleId
,
status
)
->
{
if
(
status
==
0
)
{
soundPool
.
play
(
sampleId
,
1
f
,
1
f
,
100
,
0
,
1
f
);
...
...
@@ -45,6 +42,7 @@ public class TTSHelper {
mSupportTTS
=
result
>=
TextToSpeech
.
LANG_AVAILABLE
;
}
});
mSoundIdMap
.
clear
();
}
public
static
void
speak
(
String
msg
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment