forked from recloudstream/cloudstream
fixed tv stuff
This commit is contained in:
parent
2d0c74eafe
commit
8576d9c640
4 changed files with 75 additions and 52 deletions
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
|
@ -47,7 +49,7 @@ class ParentItemAdapter(
|
||||||
val endList = mutableListOf<HomePageList>()
|
val endList = mutableListOf<HomePageList>()
|
||||||
val newFilteredList = mutableListOf<HomePageList>()
|
val newFilteredList = mutableListOf<HomePageList>()
|
||||||
for (item in newList) {
|
for (item in newList) {
|
||||||
if(item.list.isEmpty()) {
|
if (item.list.isEmpty()) {
|
||||||
endList.add(item)
|
endList.add(item)
|
||||||
} else {
|
} else {
|
||||||
newFilteredList.add(item)
|
newFilteredList.add(item)
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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"
|
<TextView
|
||||||
android:id="@+id/home_watch_child_more_info"
|
android:id="@+id/home_watch_parent_item_title"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/WatchHeaderText"
|
||||||
<TextView
|
android:layout_marginEnd="0dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:text="@string/continue_watching">
|
||||||
android:id="@+id/home_watch_parent_item_title"
|
</TextView>
|
||||||
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>
|
|
||||||
|
|
||||||
|
|
||||||
<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">
|
||||||
|
@ -426,17 +406,7 @@
|
||||||
android:text="@string/type_completed"
|
android:text="@string/type_completed"
|
||||||
style="@style/RoundedSelectableButton" />
|
style="@style/RoundedSelectableButton" />
|
||||||
</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"
|
||||||
|
@ -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>
|
||||||
|
|
||||||
|
|
32
app/src/main/res/layout/homepage_parent_tv.xml
Normal file
32
app/src/main/res/layout/homepage_parent_tv.xml
Normal 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>
|
Loading…
Reference in a new issue