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.SearchResponseDiffCallback
import com.lagradost.cloudstream3.ui.search.SearchResultBuilder
import kotlinx.android.synthetic.main.home_result_grid.view.*
class HomeChildItemAdapter(
val cardList: MutableList<SearchResponse>,
@ -59,7 +60,9 @@ class HomeChildItemAdapter(
class CardViewHolder
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 nextFocusDown: Int? = null,
) :
@ -74,8 +77,20 @@ class HomeChildItemAdapter(
else -> null
}
SearchResultBuilder.bind(clickCallback, card, position, itemView, nextFocusBehavior, nextFocusUp, nextFocusDown)
SearchResultBuilder.bind(
clickCallback,
card,
position,
itemView,
nextFocusBehavior,
nextFocusUp,
nextFocusDown
)
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)
//ani.fillAfter = true
//ani.duration = 200

View file

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

View file

@ -312,33 +312,16 @@
android:layout_width="match_parent"
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"
<TextView
android:id="@+id/home_watch_parent_item_title"
android:padding="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_gravity="center_vertical"
android:id="@+id/home_watch_parent_item_title"
style="@style/WatchHeaderText"
android:text="@string/continue_watching" />
<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>
android:layout_height="wrap_content"
style="@style/WatchHeaderText"
android:layout_marginEnd="0dp"
android:text="@string/continue_watching">
</TextView>
<androidx.recyclerview.widget.RecyclerView
android:paddingHorizontal="5dp"
@ -361,7 +344,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
<HorizontalScrollView
android:nextFocusLeft="@id/nav_rail_view"
android:nextFocusUp="@id/home_watch_child_recyclerview"
android:nextFocusForward="@id/home_bookmarked_child_recyclerview"
@ -373,16 +356,13 @@
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
<HorizontalScrollView
android:fadingEdge="horizontal"
android:requiresFadingEdge="horizontal"
android:layout_marginEnd="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:fadingEdge="horizontal"
android:requiresFadingEdge="horizontal">
<LinearLayout
android:layout_gravity="center_vertical"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
@ -426,17 +406,7 @@
android:text="@string/type_completed"
style="@style/RoundedSelectableButton" />
</LinearLayout>
</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>
</HorizontalScrollView>
<androidx.recyclerview.widget.RecyclerView
android:paddingHorizontal="5dp"
@ -457,7 +427,7 @@
android:id="@+id/home_master_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/homepage_parent" />
tools:listitem="@layout/homepage_parent_tv" />
</LinearLayout>
</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>