Przeglądaj źródła

Use getter and setter

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 11 miesięcy temu
rodzic
commit
b2696e087e

+ 1 - 1
app/src/main/java/com/nextcloud/client/jobs/transfer/FileTransferService.kt

@@ -103,7 +103,7 @@ class FileTransferService : Service() {
             return START_NOT_STICKY
         }
 
-        if (!isRunning && MainApp.lifecycle == AppLifecycle.Foreground) {
+        if (!isRunning && MainApp.getAppLifeCycle() == AppLifecycle.Foreground) {
             ForegroundServiceHelper.startService(
                 this,
                 AppNotificationManager.TRANSFER_NOTIFICATION_ID,

+ 11 - 3
app/src/main/java/com/owncloud/android/MainApp.java

@@ -376,14 +376,22 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
         registerGlobalPassCodeProtection();
     }
 
-    public static AppLifecycle lifecycle = AppLifecycle.Foreground;
+    private static AppLifecycle lifecycle = AppLifecycle.Foreground;
+
+    public static AppLifecycle getAppLifeCycle() {
+        return lifecycle;
+    }
+
+    private void setAppLifeCycle(AppLifecycle appLifecycle) {
+        lifecycle = appLifecycle;
+    }
 
     private final LifecycleEventObserver lifecycleEventObserver = ((lifecycleOwner, event) -> {
         if (event == Lifecycle.Event.ON_START) {
-            lifecycle = AppLifecycle.Foreground;
+            setAppLifeCycle(AppLifecycle.Foreground);
             Log_OC.d(TAG, "APP IN FOREGROUND");
         } else if (event == Lifecycle.Event.ON_STOP) {
-            lifecycle = AppLifecycle.Background;
+            setAppLifeCycle(AppLifecycle.Background);
             passCodeManager.setCanAskPin(true);
             Log_OC.d(TAG, "APP IN BACKGROUND");
         } else if (event == Lifecycle.Event.ON_RESUME) {