mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-09-09 11:06:17 +00:00
fix: Scope getting removed when switching between settings 'Kelvin approved'
This commit is contained in:
parent
10753eb879
commit
0d9e1cd3c5
4 changed files with 23 additions and 12 deletions
|
@ -115,6 +115,7 @@ import java.io.StringWriter
|
|||
import java.lang.reflect.InvocationTargetException
|
||||
import java.util.LinkedList
|
||||
import java.util.Queue
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.ConcurrentLinkedQueue
|
||||
|
||||
|
||||
|
@ -218,6 +219,8 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
|||
}
|
||||
}
|
||||
|
||||
val mainId = UUID.randomUUID().toString().substring(0, 5)
|
||||
|
||||
constructor() : super() {
|
||||
if (BuildConfig.DEBUG) {
|
||||
StrictMode.setVmPolicy(
|
||||
|
@ -269,8 +272,8 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
|||
|
||||
@UnstableApi
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
Logger.i(TAG, "MainActivity Starting");
|
||||
StateApp.instance.setGlobalContext(this, lifecycleScope);
|
||||
Logger.w(TAG, "MainActivity Starting [$mainId]");
|
||||
StateApp.instance.setGlobalContext(this, lifecycleScope, mainId);
|
||||
StateApp.instance.mainAppStarting(this);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -671,13 +674,13 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume();
|
||||
Logger.v(TAG, "onResume")
|
||||
Logger.w(TAG, "onResume [$mainId]")
|
||||
_isVisible = true;
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause();
|
||||
Logger.v(TAG, "onPause")
|
||||
Logger.w(TAG, "onPause [$mainId]")
|
||||
_isVisible = false;
|
||||
|
||||
_qrCodeLoadingDialog?.dismiss()
|
||||
|
@ -686,7 +689,7 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
|||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
Logger.v(TAG, "_wasStopped = true");
|
||||
Logger.w(TAG, "onStop [$mainId]");
|
||||
_wasStopped = true;
|
||||
}
|
||||
|
||||
|
@ -1103,8 +1106,8 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
|||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy();
|
||||
Logger.v(TAG, "onDestroy")
|
||||
StateApp.instance.mainAppDestroyed(this);
|
||||
Logger.w(TAG, "onDestroy [$mainId]")
|
||||
StateApp.instance.mainAppDestroyed(this, mainId);
|
||||
}
|
||||
|
||||
inline fun <reified T> isFragmentActive(): Boolean {
|
||||
|
|
|
@ -156,6 +156,8 @@ class StateApp {
|
|||
return thisContext;
|
||||
}
|
||||
|
||||
private var _mainId: String? = null;
|
||||
|
||||
//Files
|
||||
private var _tempDirectory: File? = null;
|
||||
private var _cacheDirectory: File? = null;
|
||||
|
@ -295,9 +297,12 @@ class StateApp {
|
|||
}
|
||||
|
||||
//Lifecycle
|
||||
fun setGlobalContext(context: Context, coroutineScope: CoroutineScope? = null) {
|
||||
fun setGlobalContext(context: Context, coroutineScope: CoroutineScope? = null, mainId: String? = null) {
|
||||
_mainId = mainId;
|
||||
_context = context;
|
||||
_scope = coroutineScope
|
||||
Logger.w(TAG, "Scope initialized ${(coroutineScope != null)}\n ${Log.getStackTraceString(Throwable())}")
|
||||
|
||||
}
|
||||
|
||||
fun initializeFiles(force: Boolean = false) {
|
||||
|
@ -719,7 +724,9 @@ class StateApp {
|
|||
migrateStores(context, managedStores, index + 1);
|
||||
}
|
||||
|
||||
fun mainAppDestroyed(context: Context) {
|
||||
fun mainAppDestroyed(context: Context, mainId: String? = null) {
|
||||
if (mainId != null && (_mainId != mainId || _mainId == null))
|
||||
return
|
||||
Logger.i(TAG, "App ended");
|
||||
_receiverBecomingNoisy?.let {
|
||||
_receiverBecomingNoisy = null;
|
||||
|
@ -743,7 +750,8 @@ class StateApp {
|
|||
|
||||
fun dispose(){
|
||||
_context = null;
|
||||
_scope = null;
|
||||
// _scope = null;
|
||||
Logger.w(TAG, "StateApp disposed: ${Log.getStackTraceString(Throwable())}")
|
||||
}
|
||||
|
||||
private val _connectivityEvents = object : ConnectivityManager.NetworkCallback() {
|
||||
|
|
|
@ -90,7 +90,7 @@ class ToggleField : TableRow, IField {
|
|||
|
||||
val advancedFieldAttr = field.getAnnotation(AdvancedField::class.java)
|
||||
if(advancedFieldAttr != null || advanced) {
|
||||
Logger.w("ToggleField", "Found advanced field: " + field.name);
|
||||
// Logger.w("ToggleField", "Found advanced field: " + field.name);
|
||||
isAdvanced = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<application>
|
||||
<receiver android:name=".receivers.InstallReceiver" />
|
||||
|
||||
<activity android:name=".activities.MainActivity">
|
||||
<activity android:name=".activities.MainActivity" android:launchMode="singleInstance">
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue