Переглянути джерело

Made refresh-navigation method private

Vadik Sirekanyan 7 роки тому
батько
коміт
93c3cb56e4

+ 0 - 1
app/src/main/java/com/sirekanyan/knigopis/feature/MainActivity.kt

@@ -45,7 +45,6 @@ class MainActivity : BaseActivity(), Router, MainPresenter.Router {
         super.onCreate(savedInstanceState)
         setContentView(R.layout.activity_main)
         presenter.init(savedInstanceState?.getMainState())
-        presenter.refreshNavigation()
     }
 
     override fun onStart() {

+ 9 - 9
app/src/main/java/com/sirekanyan/knigopis/feature/MainPresenter.kt

@@ -24,7 +24,6 @@ interface MainPresenter : Presenter {
     fun start()
     fun back(): Boolean
     fun refresh(tab: CurrentTab? = null, isForce: Boolean = false)
-    fun refreshNavigation()
     fun refreshOptionsMenu()
     fun showPage(tab: CurrentTab, isForce: Boolean)
 
@@ -59,6 +58,7 @@ class MainPresenterImpl(
         val currentTab = state?.currentTab?.let { CurrentTab.getByItemId(it) }
         val defaultTab = if (auth.isAuthorized()) HOME_TAB else NOTES_TAB
         refresh(currentTab ?: defaultTab)
+        refreshNavigation()
         view.setDarkThemeOptionChecked(config.isDarkTheme)
     }
 
@@ -85,14 +85,6 @@ class MainPresenterImpl(
         }
     }
 
-    override fun refreshNavigation() {
-        if (auth.isAuthorized()) {
-            view.showNavigation()
-        } else {
-            view.hideNavigation()
-        }
-    }
-
     override fun refreshOptionsMenu() {
         refreshNavigation()
         auth.isAuthorized().let { authorized ->
@@ -199,6 +191,14 @@ class MainPresenterImpl(
         router.openUserScreen(note.userId, note.userName, note.userImage)
     }
 
+    private fun refreshNavigation() {
+        if (auth.isAuthorized()) {
+            view.showNavigation()
+        } else {
+            view.hideNavigation()
+        }
+    }
+
     private fun refreshHomeTab(tab: CurrentTab) {
         bookRepository.observeBooks()
             .io2main()