From 83f637e38671c56c17c97f2ff7c68db054c7971c Mon Sep 17 00:00:00 2001 From: Colin Lee Date: Tue, 12 Feb 2019 13:56:01 -0600 Subject: [PATCH] Fixes #431: Scroll-down on the home screen messes up everything --- .../org/mozilla/fenix/home/HomeFragment.kt | 3 +- .../org/mozilla/fenix/home/HomeLayouts.kt | 56 ++++++++++--------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index aeea69fc6..97fdbbbf6 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -49,6 +49,7 @@ class HomeFragment : Fragment() { val view = inflater.inflate(R.layout.fragment_home, container, false) TabsComponent(view.homeLayout, bus, TabsState(requireComponents.core.sessionManager.sessions)) SessionsComponent(view.homeLayout, bus) + layoutComponents(view) ActionBusFactory.get(this).logMergedObservables() val activity = activity as HomeActivity DefaultThemeManager.applyStatusBarTheme(activity.window, activity.themeManager, activity) @@ -61,8 +62,6 @@ class HomeFragment : Fragment() { (activity as AppCompatActivity).supportActionBar?.hide() - layoutComponents(view.homeLayout) - getSafeManagedObservable() .subscribe { when (it) { diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeLayouts.kt b/app/src/main/java/org/mozilla/fenix/home/HomeLayouts.kt index a3a8779f6..a652f76e7 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeLayouts.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeLayouts.kt @@ -4,40 +4,42 @@ package org.mozilla.fenix.home -import androidx.constraintlayout.widget.ConstraintLayout +import android.view.View import androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.PARENT_ID -import kotlinx.android.synthetic.main.component_sessions.* -import kotlinx.android.synthetic.main.component_tabs.* -import kotlinx.android.synthetic.main.fragment_home.* -import kotlinx.android.synthetic.main.tab_list_header.* +import kotlinx.android.synthetic.main.component_sessions.view.* +import kotlinx.android.synthetic.main.component_tabs.view.* +import kotlinx.android.synthetic.main.fragment_home.view.* +import kotlinx.android.synthetic.main.tab_list_header.view.* import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.BOTTOM import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.END import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.START import org.jetbrains.anko.constraint.layout.ConstraintSetBuilder.Side.TOP import org.jetbrains.anko.constraint.layout.applyConstraintSet -fun HomeFragment.layoutComponents(layout: ConstraintLayout) { - layout.applyConstraintSet { - tabs_header { - connect( - TOP to BOTTOM of homeDivider, - START to START of tabs_list, - END to END of PARENT_ID - ) - } - tabs_list { - connect( - TOP to BOTTOM of tabs_header, - START to START of PARENT_ID, - END to END of PARENT_ID - ) - } - session_list { - connect( - TOP to BOTTOM of tabs_list, - START to START of PARENT_ID, - END to END of PARENT_ID - ) +fun HomeFragment.layoutComponents(layout: View) { + with(layout) { + homeLayout.applyConstraintSet { + tabs_header { + connect( + TOP to BOTTOM of homeDivider, + START to START of tabs_list, + END to END of PARENT_ID + ) + } + tabs_list { + connect( + TOP to BOTTOM of tabs_header, + START to START of PARENT_ID, + END to END of PARENT_ID + ) + } + session_list { + connect( + TOP to BOTTOM of tabs_list, + START to START of PARENT_ID, + END to END of PARENT_ID + ) + } } } }