diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeChildItemAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeChildItemAdapter.kt index 3f19e30f..3ce23473 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeChildItemAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeChildItemAdapter.kt @@ -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, @@ -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 diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt index 1a10a7cc..192cbef8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt @@ -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() { 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() val newFilteredList = mutableListOf() 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, private val newList: List) : +class SearchDiffCallback( + private val oldList: List, + private val newList: List +) : DiffUtil.Callback() { override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = oldList[oldItemPosition].name == newList[newItemPosition].name diff --git a/app/src/main/res/layout/fragment_home_tv.xml b/app/src/main/res/layout/fragment_home_tv.xml index 12da65f3..bf812847 100644 --- a/app/src/main/res/layout/fragment_home_tv.xml +++ b/app/src/main/res/layout/fragment_home_tv.xml @@ -312,33 +312,16 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - - - - - - + android:layout_height="wrap_content" + style="@style/WatchHeaderText" + android:layout_marginEnd="0dp" + android:text="@string/continue_watching"> + - + android:layout_height="wrap_content" - + android:fadingEdge="horizontal" + android:requiresFadingEdge="horizontal"> @@ -426,17 +406,7 @@ android:text="@string/type_completed" style="@style/RoundedSelectableButton" /> - - - - + + tools:listitem="@layout/homepage_parent_tv" /> diff --git a/app/src/main/res/layout/homepage_parent_tv.xml b/app/src/main/res/layout/homepage_parent_tv.xml new file mode 100644 index 00000000..bfbee465 --- /dev/null +++ b/app/src/main/res/layout/homepage_parent_tv.xml @@ -0,0 +1,32 @@ + + + + + + + + \ No newline at end of file