From 36785f019a4a04c1907aef1713f3ba6fca63d056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Fri, 22 Mar 2019 23:54:58 +0100 Subject: [PATCH] Fix restoring the grade fragment (#293) --- .../io/github/wulkanowy/ui/modules/grade/GradePresenter.kt | 2 +- .../java/io/github/wulkanowy/ui/modules/main/MainActivity.kt | 4 +++- .../java/io/github/wulkanowy/ui/modules/main/MainModule.kt | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradePresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradePresenter.kt index 1251ee2da..2357e0637 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradePresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradePresenter.kt @@ -77,7 +77,7 @@ class GradePresenter @Inject constructor( } fun onPageSelected(index: Int) { - loadChild(index) + if (semesters.isNotEmpty()) loadChild(index) } fun onSwipeRefresh() { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt index 5e0ed2b2f..0d9a63511 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt @@ -2,6 +2,8 @@ package io.github.wulkanowy.ui.modules.main import android.content.Context import android.content.Intent +import android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK +import android.content.Intent.FLAG_ACTIVITY_NEW_TASK import android.os.Bundle import android.view.Menu import android.view.MenuItem @@ -165,7 +167,7 @@ class MainActivity : BaseActivity(), MainView { override fun openLoginView() { startActivity(LoginActivity.getStartIntent(this) - .apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) }) + .apply { addFlags(FLAG_ACTIVITY_CLEAR_TASK or FLAG_ACTIVITY_NEW_TASK) }) } override fun onSaveInstanceState(outState: Bundle?) { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainModule.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainModule.kt index d1afd9c02..de4405b74 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainModule.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainModule.kt @@ -5,7 +5,6 @@ import dagger.Module import dagger.Provides import dagger.android.ContributesAndroidInjector import io.github.wulkanowy.R -import io.github.wulkanowy.di.scopes.PerActivity import io.github.wulkanowy.di.scopes.PerFragment import io.github.wulkanowy.ui.modules.about.AboutFragment import io.github.wulkanowy.ui.modules.about.AboutModule @@ -33,7 +32,6 @@ abstract class MainModule { companion object { @JvmStatic - @PerActivity @Provides fun provideFragNavController(activity: MainActivity): FragNavController { return FragNavController(activity.supportFragmentManager, R.id.mainFragmentContainer)