use CoordinatorLayout instead of NestedScrollView in media fragment

This commit is contained in:
Jannik 2021-02-08 00:22:50 +01:00
parent f342d1a3f4
commit e762745705
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
5 changed files with 167 additions and 151 deletions

View File

@ -11,7 +11,7 @@ android {
minSdkVersion 23
targetSdkVersion 30
versionCode 3000 //00.03.000
versionName "0.3.90"
versionName "0.3.91"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "build_time", buildTime()

View File

@ -17,9 +17,9 @@ import com.google.android.material.tabs.TabLayoutMediator
import jp.wasabeef.glide.transformations.BlurTransformation
import kotlinx.coroutines.*
import org.mosad.teapod.R
import org.mosad.teapod.databinding.FragmentMediaBinding
import org.mosad.teapod.ui.activity.main.MainActivity
import org.mosad.teapod.ui.activity.main.viewmodel.MediaFragmentViewModel
import org.mosad.teapod.databinding.FragmentMediaBinding
import org.mosad.teapod.util.*
import org.mosad.teapod.util.DataTypes.MediaType
@ -48,6 +48,8 @@ class MediaFragment(private val mediaId: Int) : Fragment() {
// tab layout and pager TODO
pagerAdapter = ScreenSlidePagerAdapter(requireActivity())
// fix material components issue #1878, if more tabs are added increase
binding.pagerEpisodesSimilar.offscreenPageLimit = 2
binding.pagerEpisodesSimilar.adapter = pagerAdapter
TabLayoutMediator(binding.tabEpisodesSimilar, binding.pagerEpisodesSimilar) { tab, position ->
tab.text = if (model.media.type == MediaType.TVSHOW && position == 0) {

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
@ -7,16 +7,23 @@
android:background="?themePrimary"
tools:context=".ui.activity.main.fragments.MediaFragment">
<androidx.core.widget.NestedScrollView
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?themePrimary">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
app:layout_scrollFlags="scroll">
<FrameLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -34,11 +41,11 @@
android:id="@+id/image_poster"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_gravity="center"
android:layout_centerInParent="true"
app:shapeAppearance="@style/ShapeAppearance.Teapod.RoundedPoster"
tools:src="@drawable/ic_launcher_background" />
</FrameLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/linear_media_info"
@ -74,6 +81,7 @@
android:layout_marginStart="7dp"
android:padding="2dp"
android:text="@string/text_episodes_count" />
</LinearLayout>
<com.google.android.material.button.MaterialButton
@ -132,9 +140,10 @@
<ImageView
android:id="@+id/image_my_list_action"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_width="36dp"
android:layout_height="36dp"
android:contentDescription="@string/my_list"
android:padding="5dp"
android:src="@drawable/ic_baseline_add_24"
app:tint="?buttonBackground" />
@ -145,6 +154,7 @@
android:text="@string/my_list"
android:textColor="?textSecondary"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
@ -152,22 +162,27 @@
android:id="@+id/tab_episodes_similar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:layout_marginStart="7dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="7dp"
app:tabMode="scrollable"
android:background="@android:color/transparent"
app:tabGravity="start"
app:tabMode="scrollable"
app:tabSelectedTextColor="?textPrimary"
app:tabTextColor="?textSecondary" />
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager_episodes_similar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="match_parent"
app:layout_anchor="@id/app_layout"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_gravity="bottom"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<FrameLayout
android:id="@+id/frame_loading"
@ -186,4 +201,4 @@
tools:visibility="visible" />
</FrameLayout>
</FrameLayout>
</RelativeLayout>

View File

@ -4,13 +4,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_episodes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
android:layout_height="match_parent"
android:paddingStart="7dp"
android:paddingEnd="7dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"

View File

@ -4,12 +4,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_media_similar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="3dp"
android:paddingTop="6dp"