--- a/app/src/main/java/com/geekorum/ttrss/articles_list/ArticleListActivity.kt Thu Feb 06 11:39:22 2020 -0400
+++ b/app/src/main/java/com/geekorum/ttrss/articles_list/ArticleListActivity.kt Thu Feb 06 11:39:03 2020 -0400
@@ -81,6 +81,7 @@
private lateinit var inAppUpdatePresenter: InAppUpdatePresenter
private lateinit var searchToolbarPresenter: SearchToolbarPresenter
private lateinit var appBarPresenter: AppBarPresenter
+ private lateinit var fabPresenter: FabPresenter
private lateinit var feedNavigationPresenter: FeedsNavigationMenuPresenter
private lateinit var accountHeaderPresenter: AccountHeaderPresenter
private lateinit var drawerLayoutPresenter: DrawerLayoutPresenter
@@ -130,25 +131,19 @@
inAppUpdatePresenter = InAppUpdatePresenter(binding.bannerContainer, this, inAppUpdateViewModel)
- navController = findNavController(R.id.middle_pane_layout).apply {
- addOnDestinationChangedListener { controller, destination, arguments ->
- when (destination.id) {
- R.id.articlesListFragment -> {
- binding.fab.show()
- }
- R.id.articlesSearchFragment -> {
- //TODO hide fab. but fab has scrollaware behavior that get it shown back when scrolling
- }
- }
- }
- }
+ navController = findNavController(R.id.middle_pane_layout)
setupToolbar()
- setUpNavigationView()
- setUpEdgeToEdge()
+ setupNavigationView()
+ setupEdgeToEdge()
+ setupFab()
}
- private fun setUpEdgeToEdge() {
+ private fun setupFab() {
+ fabPresenter = FabPresenter(binding.fab, navController)
+ }
+
+ private fun setupEdgeToEdge() {
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
@@ -187,7 +182,7 @@
appBarPresenter = AppBarPresenter(binding.appBar, binding.toolbar, navController)
}
- private fun setUpNavigationView() {
+ private fun setupNavigationView() {
binding.navigationView.setNavigationItemSelectedListener {
when(it.itemId) {
R.id.manage_feeds -> {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/geekorum/ttrss/articles_list/FabPresenter.kt Thu Feb 06 11:39:03 2020 -0400
@@ -0,0 +1,54 @@
+/*
+ * Geekttrss is a RSS feed reader application on the Android Platform.
+ *
+ * Copyright (C) 2017-2019 by Frederic-Charles Barthelery.
+ *
+ * This file is part of Geekttrss.
+ *
+ * Geekttrss is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Geekttrss is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Geekttrss. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.geekorum.ttrss.articles_list
+
+import androidx.navigation.NavController
+import androidx.navigation.dynamicfeatures.DynamicGraphNavigator
+import com.geekorum.ttrss.R
+import com.google.android.material.floatingactionbutton.FloatingActionButton
+
+/**
+ * Controls the behavior of the FloatingActionButton
+ */
+internal class FabPresenter(
+ private val fab: FloatingActionButton,
+ private val navController: NavController
+){
+
+ init {
+ setup()
+ }
+
+ private fun setup() {
+ navController.addOnDestinationChangedListener { controller, destination, arguments ->
+ val progressDestinationId = (controller.graph as? DynamicGraphNavigator.DynamicNavGraph)?.progressDestination ?: 0
+ when (destination.id) {
+ progressDestinationId -> {
+ fab.hide()
+ }
+ R.id.articlesSearchFragment -> {
+ //TODO hide fab. but fab has scrollaware behavior that get it shown back when scrolling
+ }
+ else -> fab.show()
+ }
+ }
+ }
+}