Use getter and setter

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-06-04 16:01:11 +02:00 committed by Alper Öztürk
parent e4f231d1ce
commit b2696e087e
2 changed files with 12 additions and 4 deletions

View file

@ -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,

View file

@ -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) {