Fix session handling (#67)

This commit is contained in:
Rafał Borcz 2018-03-13 18:19:04 +01:00 committed by Mikołaj Pich
parent 83b4f359bc
commit c9bdac6a66
3 changed files with 14 additions and 8 deletions

View File

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

View File

@ -37,7 +37,7 @@ public class GradesSubItem
return grade;
}
public void setSubjectAlertImage(View subjectAlertImage) {
void setSubjectAlertImage(View subjectAlertImage) {
this.subjectAlertImage = subjectAlertImage;
}

View File

@ -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<SplashContract.View>
implements SplashContract.Presenter {
@ -24,12 +23,7 @@ public class SplashPresenter extends BasePresenter<SplashContract.View>
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();
}
}
}