mirror of
https://github.com/ouchadam/small-talk.git
synced 2025-02-19 21:50:48 +01:00
fixing memory _leak_ on android Q when exiting screens
This commit is contained in:
parent
ee91de4301
commit
4b850af810
@ -1,5 +1,6 @@
|
|||||||
package app.dapk.st.core
|
package app.dapk.st.core
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
@ -20,10 +21,13 @@ abstract class DapkActivity : ComponentActivity(), EffectScope {
|
|||||||
|
|
||||||
private lateinit var themeConfig: ThemeConfig
|
private lateinit var themeConfig: ThemeConfig
|
||||||
|
|
||||||
|
private val needsBackLeakWorkaround = Build.VERSION.SDK_INT == Build.VERSION_CODES.Q
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
this.themeConfig = ThemeConfig(themeStore.isMaterialYouEnabled())
|
this.themeConfig = ThemeConfig(themeStore.isMaterialYouEnabled())
|
||||||
|
|
||||||
|
|
||||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||||
}
|
}
|
||||||
@ -53,4 +57,11 @@ abstract class DapkActivity : ComponentActivity(), EffectScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
if (needsBackLeakWorkaround && !onBackPressedDispatcher.hasEnabledCallbacks()) {
|
||||||
|
finishAfterTransition()
|
||||||
|
} else
|
||||||
|
super.onBackPressed()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user