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
9e49e89c
authored
Jun 10, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、调整ttshelper的初始化时机
2、ttshelper release时清理soundpool
parent
40103ec2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
app/src/main/java/com/bgycc/smartcanteen/activity/MainActivity.java
+1
-1
app/src/main/java/com/bgycc/smartcanteen/utils/TTSHelper.java
+4
-1
No files found.
app/src/main/java/com/bgycc/smartcanteen/activity/MainActivity.java
View file @
9e49e89c
...
@@ -101,7 +101,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
...
@@ -101,7 +101,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
super
.
attachBaseContext
(
newBase
);
super
.
attachBaseContext
(
newBase
);
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
());
if
(
deviceSN
.
isEmpty
())
{
if
(
deviceSN
.
isEmpty
())
{
LogUtils
.
file
(
TAG
,
"设备SN号为空"
);
LogUtils
.
file
(
TAG
,
"设备SN号为空"
);
...
@@ -125,6 +124,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
...
@@ -125,6 +124,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
);
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
);
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
TTSHelper
.
initialize
(
this
);
workManager
=
WorkManager
.
getInstance
(
this
);
workManager
=
WorkManager
.
getInstance
(
this
);
ViewModelFactory
factory
=
Injection
.
injectFactory
(
deviceSN
);
ViewModelFactory
factory
=
Injection
.
injectFactory
(
deviceSN
);
ViewModelProvider
provider
=
new
ViewModelProvider
(
this
,
factory
);
ViewModelProvider
provider
=
new
ViewModelProvider
(
this
,
factory
);
...
...
app/src/main/java/com/bgycc/smartcanteen/utils/TTSHelper.java
View file @
9e49e89c
...
@@ -60,13 +60,16 @@ public class TTSHelper {
...
@@ -60,13 +60,16 @@ public class TTSHelper {
}
}
public
static
void
release
()
{
public
static
void
release
()
{
mSoundIdMap
.
clear
();
if
(
mTTS
!=
null
)
{
if
(
mTTS
!=
null
)
{
mTTS
.
stop
();
mTTS
.
stop
();
}
}
if
(
mSoundPool
!=
null
)
{
if
(
mSoundPool
!=
null
)
{
for
(
int
soundId
:
mSoundIdMap
.
values
())
{
mSoundPool
.
unload
(
soundId
);
}
mSoundPool
.
release
();
mSoundPool
.
release
();
}
}
mSoundIdMap
.
clear
();
}
}
private
static
void
playSound
(
String
msg
)
{
private
static
void
playSound
(
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