Skip to content
Permalink
Browse files

Use AppBarLayout as Toolbar container

  • Loading branch information...
chrisbanes committed Oct 4, 2019
1 parent 3b74b49 commit 9fda60597ed7a58ef0c67f547870f6e14d373773
@@ -14,27 +14,25 @@
~ limitations under the License.
-->

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<layout xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/search_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.MaterialComponents.ActionBar"
app:paddingTopSystemWindowInsets="@{true}">
android:fitsSystemWindows="true">

<androidx.appcompat.widget.Toolbar
android:id="@+id/settings_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />

</FrameLayout>
</com.google.android.material.appbar.AppBarLayout>

<androidx.fragment.app.FragmentContainerView
android:id="@+id/settings_container"
@@ -28,6 +28,7 @@

<!-- Default widget styles -->
<item name="toolbarStyle">@style/Widget.Tivi.Toolbar</item>
<item name="appBarLayoutStyle">@style/Widget.MaterialComponents.AppBarLayout.Surface</item>

<!-- Type styles -->
<item name="textAppearanceHeadline1">@style/TextAppearance.Tivi.Headline1</item>
@@ -32,7 +32,7 @@ import com.airbnb.epoxy.EpoxyModel
import com.airbnb.epoxy.paging.PagedListEpoxyController

abstract class EntryGridEpoxyController<LI : EntryWithShow<out Entry>>(
@StringRes private val titleRes: Int
@StringRes private val titleRes: Int? = null
) : PagedListEpoxyController<LI>() {
var state: EntryViewState<LI> by observable(EntryViewState()) { requestForcedModelBuild() }

@@ -42,12 +42,13 @@ abstract class EntryGridEpoxyController<LI : EntryWithShow<out Entry>>(
val modelsFiltered = models.filterNotNull()

if (modelsFiltered.isNotEmpty()) {
gridHeader {
id("header")
title(titleRes)
spanSizeOverride(TotalSpanOverride)
if (titleRes != null) {
gridHeader {
id("header")
title(titleRes)
spanSizeOverride(TotalSpanOverride)
}
}

super.addModels(modelsFiltered)
} else {
emptyState {
@@ -22,7 +22,6 @@ import android.view.ActionMode
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.navigation.ui.AppBarConfiguration
@@ -34,7 +33,6 @@ import app.tivi.common.entrygrid.R
import app.tivi.common.entrygrid.databinding.FragmentEntryGridBinding
import app.tivi.data.Entry
import app.tivi.data.resultentities.EntryWithShow
import app.tivi.extensions.doOnApplyWindowInsets
import app.tivi.extensions.postponeEnterTransitionWithTimeout
import app.tivi.extensions.scheduleStartPostponedTransitions
import app.tivi.ui.ProgressTimeLatch
@@ -70,7 +68,11 @@ abstract class EntryGridFragment<LI, VM> : DaggerFragment()
}
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentEntryGridBinding.inflate(inflater, container, false)
return binding.root
}
@@ -83,15 +85,6 @@ abstract class EntryGridFragment<LI, VM> : DaggerFragment()
binding.gridSwipeRefresh.isRefreshing = it
}

binding.statusScrim.doOnApplyWindowInsets { scrim, insets, _, _ ->
val lp = scrim.layoutParams as ConstraintLayout.LayoutParams
if (lp.height != insets.systemWindowInsetTop) {
lp.height = insets.systemWindowInsetTop
lp.validate()
scrim.requestLayout()
}
}

binding.gridToolbar.setupWithNavController(findNavController(), appBarConfiguration)

binding.gridRecyclerview.apply {
@@ -20,36 +20,30 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<androidx.constraintlayout.widget.ConstraintLayout
<LinearLayout
android:id="@+id/grid_root"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">

<!-- The height of this is updated via an OnApplyWindowInsetsListener -->
<View
android:id="@+id/status_scrim"
android:layout_width="0dp"
android:layout_height="1px"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/grid_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">

<androidx.appcompat.widget.Toolbar
android:id="@+id/grid_toolbar"
android:layout_width="0dp"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.MaterialComponents.ActionBar"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/status_scrim" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/grid_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />

</com.google.android.material.appbar.AppBarLayout>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/grid_swipe_refresh"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/grid_toolbar">
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1">

<com.airbnb.epoxy.EpoxyRecyclerView
android:id="@+id/grid_recyclerview"
@@ -62,12 +56,12 @@
android:paddingRight="2dp"
android:paddingTop="2dp"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:paddingBottomSystemWindowInsets="@{ true }"
app:paddingBottomSystemWindowInsets="@{true}"
app:spanCount="@integer/grid_span_count"
tools:listitem="@layout/view_holder_poster_grid_item" />

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

</layout>
@@ -20,7 +20,7 @@
<dimen name="header_margin">14dp</dimen>
<dimen name="image_round_rect_radius">4dp</dimen>

<dimen name="details_appbar_elevation">4dp</dimen>
<dimen name="elevation_appbar">4dp</dimen>

<dimen name="spacing_xlarge">48dp</dimen>
<dimen name="spacing_large">24dp</dimen>
@@ -21,26 +21,26 @@
xmlns:tools="http://schemas.android.com/tools">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/followed_root"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/followed_app_bar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.MaterialComponents.ActionBar"
android:fitsSystemWindows="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:paddingTopSystemWindowInsets="@{true}">
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.Toolbar
android:id="@+id/discover_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:menu="@menu/discover_toolbar" />

</FrameLayout>
</com.google.android.material.appbar.AppBarLayout>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/summary_swipe_refresh"
@@ -28,7 +28,6 @@ import androidx.navigation.fragment.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupWithNavController
import app.tivi.DaggerMvRxFragment
import app.tivi.common.epoxy.StickyHeaderScrollListener
import app.tivi.common.imageloading.loadImageUrl
import app.tivi.data.entities.SortOption
import app.tivi.data.resultentities.FollowedShowEntryWithShow
@@ -125,7 +124,6 @@ class FollowedFragment : DaggerMvRxFragment() {

binding.followedRv.apply {
addItemDecoration(SpacingItemDecorator(paddingLeft))
addOnScrollListener(StickyHeaderScrollListener(controller, controller::isHeader, binding.headerHolder))
addOnScrollListener(HideImeOnScrollListener())
setController(controller)
}
@@ -23,23 +23,22 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/followed_app_bar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.MaterialComponents.ActionBar"
android:fitsSystemWindows="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:paddingTopSystemWindowInsets="@{true}">
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.Toolbar
android:id="@+id/followed_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:menu="@menu/followed_toolbar" />

</FrameLayout>
</com.google.android.material.appbar.AppBarLayout>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/followed_swipe_refresh"
@@ -63,16 +62,6 @@

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

<app.tivi.ui.widget.HeaderHolderFrameLayout
android:id="@+id/header_holder"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:dividerMarginEnd="@dimen/spacing_normal"
app:dividerMarginStart="@dimen/spacing_normal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/followed_swipe_refresh" />

</androidx.constraintlayout.widget.ConstraintLayout>

<data>
@@ -91,14 +91,14 @@
<CustomAttribute
app:attributeName="iconTint"
app:customColorValue="?android:attr/textColorPrimary" />
<Transform android:elevation="@dimen/details_appbar_elevation" />
<Transform android:elevation="@dimen/elevation_appbar" />
</Constraint>

<Constraint
android:id="@id/details_appbar_background"
android:layout_width="0dp"
android:layout_height="?android:attr/actionBarSize"
android:elevation="@dimen/details_appbar_elevation"
android:elevation="@dimen/elevation_appbar"
app:layout_constraintEnd_toEndOf="@id/details_rv"
app:layout_constraintStart_toStartOf="@id/details_rv"
app:layout_constraintTop_toBottomOf="@id/details_status_bar_anchor">
@@ -117,7 +117,7 @@
android:layout_marginEnd="@dimen/spacing_xlarge"
android:layout_marginStart="64dp"
android:layout_marginTop="@dimen/spacing_micro"
android:elevation="@dimen/details_appbar_elevation"
android:elevation="@dimen/elevation_appbar"
app:layout_constraintBottom_toBottomOf="@id/details_appbar_background"
app:layout_constraintEnd_toEndOf="@id/details_appbar_background"
app:layout_constraintStart_toStartOf="@id/details_appbar_background"
@@ -143,7 +143,7 @@
app:attributeName="backgroundColor"
app:customColorValue="?android:attr/colorBackground" />

<Transform android:elevation="@dimen/details_appbar_elevation" />
<Transform android:elevation="@dimen/elevation_appbar" />
</Constraint>

<Constraint android:id="@id/details_follow_fab">
@@ -28,7 +28,6 @@ import androidx.navigation.fragment.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupWithNavController
import app.tivi.DaggerMvRxFragment
import app.tivi.common.epoxy.StickyHeaderScrollListener
import app.tivi.common.imageloading.loadImageUrl
import app.tivi.data.entities.SortOption
import app.tivi.data.resultentities.WatchedShowEntryWithShow
@@ -125,7 +124,6 @@ class WatchedFragment : DaggerMvRxFragment() {

binding.watchedRv.apply {
addItemDecoration(SpacingItemDecorator(paddingLeft))
addOnScrollListener(StickyHeaderScrollListener(controller, controller::isHeader, binding.headerHolder))
addOnScrollListener(HideImeOnScrollListener())
setController(controller)
}
@@ -20,26 +20,26 @@
xmlns:tools="http://schemas.android.com/tools">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/watched_root"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/watched_app_bar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.MaterialComponents.ActionBar"
android:fitsSystemWindows="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:paddingTopSystemWindowInsets="@{true}">
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.Toolbar
android:id="@+id/watched_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:menu="@menu/watched_toolbar"/>

</FrameLayout>
</com.google.android.material.appbar.AppBarLayout>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/watched_swipe_refresh"
@@ -63,16 +63,6 @@

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

<app.tivi.ui.widget.HeaderHolderFrameLayout
android:id="@+id/header_holder"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:dividerMarginEnd="@dimen/spacing_normal"
app:dividerMarginStart="@dimen/spacing_normal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/watched_swipe_refresh" />

</androidx.constraintlayout.widget.ConstraintLayout>

<data>

0 comments on commit 9fda605

Please sign in to comment.
You can’t perform that action at this time.