From c9bdac6a66533918f739ae30cb01f0411794c4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Tue, 13 Mar 2018 18:19:04 +0100 Subject: [PATCH] Fix session handling (#67) --- .../main/java/io/github/wulkanowy/WulkanowyApp.java | 12 ++++++++++++ .../wulkanowy/ui/main/grades/GradesSubItem.java | 2 +- .../github/wulkanowy/ui/splash/SplashPresenter.java | 8 +------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.java b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.java index 4b8866ce..8e5318e1 100644 --- a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.java +++ b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.java @@ -16,6 +16,7 @@ import io.github.wulkanowy.data.RepositoryContract; import io.github.wulkanowy.di.component.ApplicationComponent; import io.github.wulkanowy.di.component.DaggerApplicationComponent; import io.github.wulkanowy.di.modules.ApplicationModule; +import io.github.wulkanowy.utils.LogUtils; public class WulkanowyApp extends Application { @@ -37,6 +38,17 @@ public class WulkanowyApp extends Application { enableDebugLog(); } initializeFabric(); + initializeUserSession(); + } + + private void initializeUserSession() { + if (repository.getCurrentUserId() != 0) { + try { + repository.initLastUser(); + } catch (Exception e) { + LogUtils.error("An error occurred when the application was started", e); + } + } } private void enableDebugLog() { diff --git a/app/src/main/java/io/github/wulkanowy/ui/main/grades/GradesSubItem.java b/app/src/main/java/io/github/wulkanowy/ui/main/grades/GradesSubItem.java index 102a232f..e8bd71ca 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/main/grades/GradesSubItem.java +++ b/app/src/main/java/io/github/wulkanowy/ui/main/grades/GradesSubItem.java @@ -37,7 +37,7 @@ public class GradesSubItem return grade; } - public void setSubjectAlertImage(View subjectAlertImage) { + void setSubjectAlertImage(View subjectAlertImage) { this.subjectAlertImage = subjectAlertImage; } diff --git a/app/src/main/java/io/github/wulkanowy/ui/splash/SplashPresenter.java b/app/src/main/java/io/github/wulkanowy/ui/splash/SplashPresenter.java index d617b4af..c3d81215 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/splash/SplashPresenter.java +++ b/app/src/main/java/io/github/wulkanowy/ui/splash/SplashPresenter.java @@ -6,7 +6,6 @@ import javax.inject.Inject; import io.github.wulkanowy.data.RepositoryContract; import io.github.wulkanowy.ui.base.BasePresenter; -import io.github.wulkanowy.utils.LogUtils; public class SplashPresenter extends BasePresenter implements SplashContract.Presenter { @@ -24,12 +23,7 @@ public class SplashPresenter extends BasePresenter if (getRepository().getCurrentUserId() == 0) { getView().openLoginActivity(); } else { - try { - getRepository().initLastUser(); - getView().openMainActivity(); - } catch (Exception e) { - LogUtils.error("An error occurred when the application was started", e); - } + getView().openMainActivity(); } } }