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> </value>
</option> </option>
</component> </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" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

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

View File

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

View File

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