Skip to content

Commit 3deeaee

Browse files
committed
Use getter and setter
Signed-off-by: alperozturk <[email protected]>
1 parent 94f3042 commit 3deeaee

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class FileTransferService : Service() {
103103
return START_NOT_STICKY
104104
}
105105

106-
if (!isRunning && MainApp.lifecycle == AppLifecycle.Foreground) {
106+
if (!isRunning && MainApp.getAppLifeCycle() == AppLifecycle.Foreground) {
107107
ForegroundServiceHelper.startService(
108108
this,
109109
AppNotificationManager.TRANSFER_NOTIFICATION_ID,

app/src/main/java/com/owncloud/android/MainApp.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,22 @@ public void onCreate() {
376376
registerGlobalPassCodeProtection();
377377
}
378378

379-
public static AppLifecycle lifecycle = AppLifecycle.Foreground;
379+
private static AppLifecycle lifecycle = AppLifecycle.Foreground;
380+
381+
public static AppLifecycle getAppLifeCycle() {
382+
return lifecycle;
383+
}
384+
385+
private void setAppLifeCycle(AppLifecycle appLifecycle) {
386+
lifecycle = appLifecycle;
387+
}
380388

381389
private final LifecycleEventObserver lifecycleEventObserver = ((lifecycleOwner, event) -> {
382390
if (event == Lifecycle.Event.ON_START) {
383-
lifecycle = AppLifecycle.Foreground;
391+
setAppLifeCycle(AppLifecycle.Foreground);
384392
Log_OC.d(TAG, "APP IN FOREGROUND");
385393
} else if (event == Lifecycle.Event.ON_STOP) {
386-
lifecycle = AppLifecycle.Background;
394+
setAppLifeCycle(AppLifecycle.Background);
387395
passCodeManager.setCanAskPin(true);
388396
Log_OC.d(TAG, "APP IN BACKGROUND");
389397
} else if (event == Lifecycle.Event.ON_RESUME) {

0 commit comments

Comments
 (0)