fixed tv stuff

This commit is contained in:
LagradOst 2022-03-29 23:07:41 +02:00
parent 2d0c74eafe
commit 8576d9c640
4 changed files with 75 additions and 52 deletions

View file

@ -10,6 +10,7 @@ import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.ui.search.SearchClickCallback import com.lagradost.cloudstream3.ui.search.SearchClickCallback
import com.lagradost.cloudstream3.ui.search.SearchResponseDiffCallback import com.lagradost.cloudstream3.ui.search.SearchResponseDiffCallback
import com.lagradost.cloudstream3.ui.search.SearchResultBuilder import com.lagradost.cloudstream3.ui.search.SearchResultBuilder
import kotlinx.android.synthetic.main.home_result_grid.view.*
class HomeChildItemAdapter( class HomeChildItemAdapter(
val cardList: MutableList<SearchResponse>, val cardList: MutableList<SearchResponse>,
@ -59,7 +60,9 @@ class HomeChildItemAdapter(
class CardViewHolder class CardViewHolder
constructor( constructor(
itemView: View, private val clickCallback: (SearchClickCallback) -> Unit, private val itemCount: Int, itemView: View,
private val clickCallback: (SearchClickCallback) -> Unit,
private val itemCount: Int,
private val nextFocusUp: Int? = null, private val nextFocusUp: Int? = null,
private val nextFocusDown: Int? = null, private val nextFocusDown: Int? = null,
) : ) :
@ -74,8 +77,20 @@ class HomeChildItemAdapter(
else -> null else -> null
} }
SearchResultBuilder.bind(clickCallback, card, position, itemView, nextFocusBehavior, nextFocusUp, nextFocusDown) SearchResultBuilder.bind(
clickCallback,
card,
position,
itemView,
nextFocusBehavior,
nextFocusUp,
nextFocusDown
)
itemView.tag = position itemView.tag = position
if (position == 0) { // to fix tv
itemView.backgroundCard?.nextFocusLeftId = R.id.nav_rail_view
}
//val ani = ScaleAnimation(0.9f, 1.0f, 0.9f, 1f) //val ani = ScaleAnimation(0.9f, 1.0f, 0.9f, 1f)
//ani.fillAfter = true //ani.fillAfter = true
//ani.duration = 200 //ani.duration = 200

View file

@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.lagradost.cloudstream3.HomePageList import com.lagradost.cloudstream3.HomePageList
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.ui.search.SearchClickCallback import com.lagradost.cloudstream3.ui.search.SearchClickCallback
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
import kotlinx.android.synthetic.main.homepage_parent.view.* import kotlinx.android.synthetic.main.homepage_parent.view.*
class ParentItemAdapter( class ParentItemAdapter(
@ -18,7 +19,8 @@ class ParentItemAdapter(
private val moreInfoClickCallback: (HomePageList) -> Unit, private val moreInfoClickCallback: (HomePageList) -> Unit,
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { ) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, i: Int): ParentViewHolder { override fun onCreateViewHolder(parent: ViewGroup, i: Int): ParentViewHolder {
val layout = R.layout.homepage_parent val layout =
if (parent.context.isTvSettings()) R.layout.homepage_parent_tv else R.layout.homepage_parent
return ParentViewHolder( return ParentViewHolder(
LayoutInflater.from(parent.context).inflate(layout, parent, false), LayoutInflater.from(parent.context).inflate(layout, parent, false),
clickCallback, clickCallback,
@ -56,7 +58,8 @@ class ParentItemAdapter(
newFilteredList.addAll(endList) newFilteredList.addAll(endList)
val diffResult = DiffUtil.calculateDiff( val diffResult = DiffUtil.calculateDiff(
SearchDiffCallback(this.items, newFilteredList)) SearchDiffCallback(this.items, newFilteredList)
)
items.clear() items.clear()
items.addAll(newFilteredList) items.addAll(newFilteredList)
@ -73,7 +76,7 @@ class ParentItemAdapter(
RecyclerView.ViewHolder(itemView) { RecyclerView.ViewHolder(itemView) {
val title: TextView = itemView.home_parent_item_title val title: TextView = itemView.home_parent_item_title
val recyclerView: RecyclerView = itemView.home_child_recyclerview val recyclerView: RecyclerView = itemView.home_child_recyclerview
private val moreInfo: FrameLayout = itemView.home_child_more_info private val moreInfo: FrameLayout? = itemView.home_child_more_info
fun bind(info: HomePageList) { fun bind(info: HomePageList) {
title.text = info.name title.text = info.name
recyclerView.adapter = HomeChildItemAdapter( recyclerView.adapter = HomeChildItemAdapter(
@ -84,14 +87,17 @@ class ParentItemAdapter(
) )
//(recyclerView.adapter as HomeChildItemAdapter).notifyDataSetChanged() //(recyclerView.adapter as HomeChildItemAdapter).notifyDataSetChanged()
moreInfo.setOnClickListener { moreInfo?.setOnClickListener {
moreInfoClickCallback.invoke(info) moreInfoClickCallback.invoke(info)
} }
} }
} }
} }
class SearchDiffCallback(private val oldList: List<HomePageList>, private val newList: List<HomePageList>) : class SearchDiffCallback(
private val oldList: List<HomePageList>,
private val newList: List<HomePageList>
) :
DiffUtil.Callback() { DiffUtil.Callback() {
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) =
oldList[oldItemPosition].name == newList[newItemPosition].name oldList[oldItemPosition].name == newList[newItemPosition].name

View file

@ -312,33 +312,16 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<FrameLayout
android:nextFocusLeft="@id/nav_rail_view"
android:nextFocusUp="@id/home_main_info"
android:nextFocusDown="@id/home_watch_child_recyclerview"
android:foreground="?android:attr/selectableItemBackgroundBorderless"
android:id="@+id/home_watch_child_more_info"
android:padding="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView <TextView
android:layout_gravity="center_vertical"
android:id="@+id/home_watch_parent_item_title" android:id="@+id/home_watch_parent_item_title"
android:padding="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/WatchHeaderText" style="@style/WatchHeaderText"
android:text="@string/continue_watching" /> android:layout_marginEnd="0dp"
android:text="@string/continue_watching">
<ImageView </TextView>
app:tint="?attr/textColor"
android:layout_marginEnd="5dp"
android:layout_gravity="end|center_vertical"
android:src="@drawable/ic_baseline_arrow_forward_24"
android:layout_width="30dp"
android:layout_height="match_parent"
android:contentDescription="@string/home_more_info" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:paddingHorizontal="5dp" android:paddingHorizontal="5dp"
@ -361,7 +344,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<FrameLayout <HorizontalScrollView
android:nextFocusLeft="@id/nav_rail_view" android:nextFocusLeft="@id/nav_rail_view"
android:nextFocusUp="@id/home_watch_child_recyclerview" android:nextFocusUp="@id/home_watch_child_recyclerview"
android:nextFocusForward="@id/home_bookmarked_child_recyclerview" android:nextFocusForward="@id/home_bookmarked_child_recyclerview"
@ -373,16 +356,13 @@
android:paddingStart="12dp" android:paddingStart="12dp"
android:paddingEnd="12dp" android:paddingEnd="12dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
<HorizontalScrollView
android:fadingEdge="horizontal" android:fadingEdge="horizontal"
android:requiresFadingEdge="horizontal" android:requiresFadingEdge="horizontal">
android:layout_marginEnd="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:layout_gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -428,16 +408,6 @@
</LinearLayout> </LinearLayout>
</HorizontalScrollView> </HorizontalScrollView>
<ImageView
app:tint="?attr/textColor"
android:layout_marginEnd="5dp"
android:layout_gravity="end|center_vertical"
android:src="@drawable/ic_baseline_arrow_forward_24"
android:layout_width="30dp"
android:layout_height="match_parent"
android:contentDescription="@string/home_more_info" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:paddingHorizontal="5dp" android:paddingHorizontal="5dp"
android:clipToPadding="false" android:clipToPadding="false"
@ -457,7 +427,7 @@
android:id="@+id/home_master_recycler" android:id="@+id/home_master_recycler"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:listitem="@layout/homepage_parent" /> tools:listitem="@layout/homepage_parent_tv" />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/home_parent_item_title"
android:padding="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/WatchHeaderText"
android:layout_marginEnd="0dp"
tools:text="Trending">
</TextView>
<androidx.recyclerview.widget.RecyclerView
android:nextFocusUp="@id/home_child_more_info"
android:paddingHorizontal="5dp"
android:clipToPadding="false"
android:descendantFocusability="afterDescendants"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:id="@+id/home_child_recyclerview"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:listitem="@layout/home_result_grid" />
</LinearLayout>