improve lifecycle

This commit is contained in:
adrienmalin 2018-12-17 08:01:56 +01:00
parent 0dcef96194
commit c1193f2166
4 changed files with 28 additions and 18 deletions

2
.idea/misc.xml generated
View File

@ -29,7 +29,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -10,8 +10,8 @@ android {
applicationId "adrienmalin.pingpoints"
minSdkVersion 15
targetSdkVersion 28
versionCode 8
versionName "2.1"
versionCode 9
versionName "2.3"
vectorDrawables.useSupportLibrary true
}
buildTypes {

View File

@ -104,6 +104,17 @@ class SttDialog : DialogFragment() {
putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true)
putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true)
}
}
}
}
}.create()!!
override fun onResume() {
super.onResume()
matchActivity?.apply {
matchModel?.apply {
stt?.destroy()
stt = SpeechRecognizer.createSpeechRecognizer(activity).apply {
setRecognitionListener(SttListener())
try {
@ -118,13 +129,12 @@ class SttDialog : DialogFragment() {
}
}
}
}.create()!!
override fun onStop() {
override fun onPause() {
unMuteAudio()
stt?.stopListening()
stt?.destroy()
super.onStop()
super.onPause()
}
@Suppress("DEPRECATION")

View File

@ -28,7 +28,6 @@ class VictoryActivity : AppCompatActivity() {
previousMatch = getPreferences(Context.MODE_PRIVATE)
initVictoryModel()
updateUI()
saveScore()
}
fun initVictoryModel() {
@ -76,7 +75,7 @@ class VictoryActivity : AppCompatActivity() {
}
}
fun saveScore() {
override fun onStop() {
victoryModel?.apply {
previousMatch?.edit()?.apply {
putString(
@ -92,6 +91,7 @@ class VictoryActivity : AppCompatActivity() {
commit()
}
}
super.onStop()
}
fun newMatch(view: View) {