expandable resume watching go brrr

This commit is contained in:
reduplicated 2023-01-21 20:05:37 +01:00
parent b2b894caa9
commit 65fda1889c
6 changed files with 155 additions and 104 deletions

View file

@ -184,9 +184,8 @@ open class ParentItemAdapter(
private val expandCallback: ((String) -> Unit)? = null, private val expandCallback: ((String) -> Unit)? = null,
) : ) :
RecyclerView.ViewHolder(itemView) { RecyclerView.ViewHolder(itemView) {
val title: TextView = itemView.home_parent_item_title val title: TextView = itemView.home_child_more_info
val recyclerView: RecyclerView = itemView.home_child_recyclerview val recyclerView: RecyclerView = itemView.home_child_recyclerview
private val moreInfo: FrameLayout? = itemView.home_child_more_info
fun update(expand: HomeViewModel.ExpandableHomepageList) { fun update(expand: HomeViewModel.ExpandableHomepageList) {
val info = expand.list val info = expand.list
@ -248,9 +247,10 @@ open class ParentItemAdapter(
}) })
//(recyclerView.adapter as HomeChildItemAdapter).notifyDataSetChanged() //(recyclerView.adapter as HomeChildItemAdapter).notifyDataSetChanged()
if (!isTvSettings()) {
moreInfo?.setOnClickListener { title.setOnClickListener {
moreInfoClickCallback.invoke(expand) moreInfoClickCallback.invoke(expand)
}
} }
} }
} }

View file

@ -14,6 +14,7 @@ import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipDrawable import com.google.android.material.chip.ChipDrawable
import com.lagradost.cloudstream3.APIHolder.getId import com.lagradost.cloudstream3.APIHolder.getId
import com.lagradost.cloudstream3.AcraApplication.Companion.getActivity import com.lagradost.cloudstream3.AcraApplication.Companion.getActivity
import com.lagradost.cloudstream3.HomePageList
import com.lagradost.cloudstream3.LoadResponse import com.lagradost.cloudstream3.LoadResponse
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.SearchResponse import com.lagradost.cloudstream3.SearchResponse
@ -31,9 +32,10 @@ import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showOptionSelectSt
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbarView import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbarView
import com.lagradost.cloudstream3.utils.UIHelper.setImage import com.lagradost.cloudstream3.utils.UIHelper.setImage
import kotlinx.android.synthetic.main.activity_main_tv.view.* import kotlinx.android.synthetic.main.activity_main.view.*
import kotlinx.android.synthetic.main.fragment_home_head.view.* import kotlinx.android.synthetic.main.fragment_home_head.view.*
import kotlinx.android.synthetic.main.fragment_home_head.view.home_bookmarked_child_recyclerview import kotlinx.android.synthetic.main.fragment_home_head.view.home_bookmarked_child_recyclerview
import kotlinx.android.synthetic.main.fragment_home_head.view.home_watch_parent_item_title
import kotlinx.android.synthetic.main.fragment_home_head_tv.view.* import kotlinx.android.synthetic.main.fragment_home_head_tv.view.*
import kotlinx.android.synthetic.main.fragment_home_head_tv.view.home_bookmarked_holder import kotlinx.android.synthetic.main.fragment_home_head_tv.view.home_bookmarked_holder
import kotlinx.android.synthetic.main.fragment_home_head_tv.view.home_none_padding import kotlinx.android.synthetic.main.fragment_home_head_tv.view.home_none_padding
@ -46,11 +48,12 @@ import kotlinx.android.synthetic.main.fragment_home_head_tv.view.home_type_on_ho
import kotlinx.android.synthetic.main.fragment_home_head_tv.view.home_type_watching_btt import kotlinx.android.synthetic.main.fragment_home_head_tv.view.home_type_watching_btt
import kotlinx.android.synthetic.main.fragment_home_head_tv.view.home_watch_child_recyclerview import kotlinx.android.synthetic.main.fragment_home_head_tv.view.home_watch_child_recyclerview
import kotlinx.android.synthetic.main.fragment_home_head_tv.view.home_watch_holder import kotlinx.android.synthetic.main.fragment_home_head_tv.view.home_watch_holder
import kotlinx.android.synthetic.main.toast.view.*
class HomeParentItemAdapterPreview( class HomeParentItemAdapterPreview(
items: MutableList<HomeViewModel.ExpandableHomepageList>, items: MutableList<HomeViewModel.ExpandableHomepageList>,
val clickCallback: (SearchClickCallback) -> Unit, val clickCallback: (SearchClickCallback) -> Unit,
moreInfoClickCallback: (HomeViewModel.ExpandableHomepageList) -> Unit, private val moreInfoClickCallback: (HomeViewModel.ExpandableHomepageList) -> Unit,
expandCallback: ((String) -> Unit)? = null, expandCallback: ((String) -> Unit)? = null,
private val loadCallback: (LoadClickCallback) -> Unit, private val loadCallback: (LoadClickCallback) -> Unit,
private val loadMoreCallback: (() -> Unit), private val loadMoreCallback: (() -> Unit),
@ -136,7 +139,8 @@ class HomeParentItemAdapterPreview(
clickCallback, clickCallback,
reloadStored, reloadStored,
loadStoredData, loadStoredData,
searchQueryCallback searchQueryCallback,
moreInfoClickCallback
).also { ).also {
this.holder = it this.holder = it
} }
@ -182,7 +186,8 @@ class HomeParentItemAdapterPreview(
private val searchClickCallback: (SearchClickCallback) -> Unit, private val searchClickCallback: (SearchClickCallback) -> Unit,
private val reloadStored: () -> Unit, private val reloadStored: () -> Unit,
private val loadStoredData: ((Set<WatchType>) -> Unit), private val loadStoredData: ((Set<WatchType>) -> Unit),
private val searchQueryCallback: ((Pair<Boolean, String>) -> Unit) private val searchQueryCallback: ((Pair<Boolean, String>) -> Unit),
private val moreInfoClickCallback: (HomeViewModel.ExpandableHomepageList) -> Unit
) : RecyclerView.ViewHolder(itemView) { ) : RecyclerView.ViewHolder(itemView) {
private var previewAdapter: HomeScrollAdapter? = null private var previewAdapter: HomeScrollAdapter? = null
private val previewViewpager: ViewPager2? = itemView.home_preview_viewpager private val previewViewpager: ViewPager2? = itemView.home_preview_viewpager
@ -602,11 +607,43 @@ class HomeParentItemAdapterPreview(
fun updateResume(resumeWatching: List<SearchResponse>) { fun updateResume(resumeWatching: List<SearchResponse>) {
resumeHolder?.isVisible = resumeWatching.isNotEmpty() resumeHolder?.isVisible = resumeWatching.isNotEmpty()
resumeAdapter?.updateList(resumeWatching) resumeAdapter?.updateList(resumeWatching)
if (!isTvSettings()) {
itemView.home_watch_parent_item_title?.setOnClickListener {
moreInfoClickCallback.invoke(
HomeViewModel.ExpandableHomepageList(
HomePageList(
itemView.home_watch_parent_item_title?.text.toString(),
resumeWatching,
false
), 1, false
)
)
}
}
} }
fun updateBookmarks(data: Pair<Boolean, List<SearchResponse>>) { fun updateBookmarks(data: Pair<Boolean, List<SearchResponse>>) {
bookmarkHolder?.isVisible = data.first bookmarkHolder?.isVisible = data.first
bookmarkAdapter?.updateList(data.second) bookmarkAdapter?.updateList(data.second)
if (!isTvSettings()) {
itemView.home_bookmark_parent_item_title?.setOnClickListener {
val items = toggleList.mapNotNull { it.first }.filter { it.isChecked }
if (items.isEmpty()) return@setOnClickListener // we don't want to show an empty dialog
val textSum = items
.mapNotNull { it.text }.joinToString()
moreInfoClickCallback.invoke(
HomeViewModel.ExpandableHomepageList(
HomePageList(
textSum,
data.second,
false
), 1, false
)
)
}
}
} }
fun setAvailableWatchStatusTypes(availableWatchStatusTypes: Pair<Set<WatchType>, Set<WatchType>>) { fun setAvailableWatchStatusTypes(availableWatchStatusTypes: Pair<Set<WatchType>, Set<WatchType>>) {

View file

@ -421,7 +421,6 @@ class ResultViewModel2 : ViewModel() {
fun updateWatchStatus(currentResponse: LoadResponse, status: WatchType) { fun updateWatchStatus(currentResponse: LoadResponse, status: WatchType) {
val currentId = currentResponse.getId() val currentId = currentResponse.getId()
val resultPage = currentResponse
DataStoreHelper.setResultWatchState(currentId, status.internalId) DataStoreHelper.setResultWatchState(currentId, status.internalId)
val current = DataStoreHelper.getBookmarkedData(currentId) val current = DataStoreHelper.getBookmarkedData(currentId)
@ -432,12 +431,12 @@ class ResultViewModel2 : ViewModel() {
currentId, currentId,
current?.bookmarkedTime ?: currentTime, current?.bookmarkedTime ?: currentTime,
currentTime, currentTime,
resultPage.name, currentResponse.name,
resultPage.url, currentResponse.url,
resultPage.apiName, currentResponse.apiName,
resultPage.type, currentResponse.type,
resultPage.posterUrl, currentResponse.posterUrl,
resultPage.year currentResponse.year
) )
) )
} }
@ -1628,7 +1627,7 @@ class ResultViewModel2 : ViewModel() {
if (ranges?.contains(range) != true) { if (ranges?.contains(range) != true) {
// if the current ranges does not include the range then select the range with the closest matching start episode // if the current ranges does not include the range then select the range with the closest matching start episode
// this usually happends when dub has less episodes then sub -> the range does not exist // this usually happends when dub has less episodes then sub -> the range does not exist
ranges?.minByOrNull { abs(it.startEpisode - range.startEpisode) }?.let { r -> ranges?.minByOrNull { kotlin.math.abs(it.startEpisode - range.startEpisode) }?.let { r ->
postEpisodeRange(indexer, r) postEpisodeRange(indexer, r)
return return
} }

View file

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/home_header" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/home_header"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/primaryBlackBackground" android:background="?attr/primaryBlackBackground"
xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical">
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<View <View
android:id="@+id/home_none_padding" android:id="@+id/home_none_padding"
@ -16,8 +16,10 @@
<FrameLayout <FrameLayout
android:id="@+id/home_preview" android:id="@+id/home_preview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="500dp"> android:layout_height="500dp"
tools:visibility="gone">
<androidx.viewpager2.widget.ViewPager2 <androidx.viewpager2.widget.ViewPager2
android:id="@+id/home_preview_viewpager" android:id="@+id/home_preview_viewpager"
@ -52,10 +54,10 @@
android:iconifiedByDefault="true" android:iconifiedByDefault="true"
android:textColor="@color/white" android:textColor="@color/white"
android:textColorHint="@color/white" android:textColorHint="@color/white"
app:closeIcon="@drawable/ic_baseline_close_24"
app:iconifiedByDefault="true" app:iconifiedByDefault="true"
app:queryBackground="@color/transparent" app:queryBackground="@color/transparent"
app:queryHint="@string/search_hint" app:queryHint="@string/search_hint"
app:closeIcon="@drawable/ic_baseline_close_24"
app:searchIcon="@drawable/search_icon" app:searchIcon="@drawable/search_icon"
tools:ignore="RtlSymmetry" /> tools:ignore="RtlSymmetry" />
@ -80,7 +82,6 @@
--> -->
<LinearLayout <LinearLayout
android:id="@+id/home_preview_title_holder" android:id="@+id/home_preview_title_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="100dp" android:layout_height="100dp"
@ -156,7 +157,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="0dp" android:layout_marginEnd="0dp"
android:padding="12dp" android:padding="12dp"
android:text="@string/continue_watching" /> android:text="@string/continue_watching"
app:drawableRightCompat="@drawable/ic_baseline_arrow_forward_24"
app:drawableTint="?attr/white"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/home_more_info"/>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_watch_child_recyclerview" android:id="@+id/home_watch_child_recyclerview"
@ -179,77 +184,96 @@
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"> tools:visibility="visible">
<HorizontalScrollView <FrameLayout
android:id="@+id/home_bookmark_parent_item_title"
android:background="?android:attr/selectableItemBackground"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:fadingEdge="horizontal"
android:foreground="?android:attr/selectableItemBackgroundBorderless" <HorizontalScrollView
android:nextFocusLeft="@id/nav_rail_view" android:layout_width="match_parent"
android:nextFocusUp="@id/home_watch_child_recyclerview"
android:nextFocusForward="@id/home_bookmarked_child_recyclerview"
android:paddingStart="12dp"
android:paddingTop="5dp"
android:paddingEnd="12dp"
android:paddingBottom="5dp"
android:requiresFadingEdge="horizontal">
<com.google.android.material.chip.ChipGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:layout_marginEnd="50dp"
android:fadingEdge="horizontal"
<com.google.android.material.chip.Chip android:nextFocusLeft="@id/nav_rail_view"
android:id="@+id/home_type_watching_btt" android:nextFocusUp="@id/home_watch_child_recyclerview"
style="@style/ChipFilled" android:nextFocusForward="@id/home_bookmarked_child_recyclerview"
android:paddingStart="12dp"
android:paddingTop="5dp"
android:paddingEnd="12dp"
android:paddingBottom="5dp"
android:requiresFadingEdge="horizontal">
<com.google.android.material.chip.ChipGroup
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal">
android:nextFocusLeft="@id/nav_rail_view" <com.google.android.material.chip.Chip
android:nextFocusRight="@id/home_plan_to_watch_btt" android:id="@+id/home_type_watching_btt"
android:text="@string/type_watching" /> style="@style/ChipFilled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<com.google.android.material.chip.Chip android:nextFocusLeft="@id/nav_rail_view"
android:id="@+id/home_plan_to_watch_btt" android:nextFocusRight="@id/home_plan_to_watch_btt"
style="@style/ChipFilled" android:text="@string/type_watching" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:nextFocusLeft="@id/home_type_watching_btt" <com.google.android.material.chip.Chip
android:nextFocusRight="@id/home_type_on_hold_btt" android:id="@+id/home_plan_to_watch_btt"
android:text="@string/type_plan_to_watch" /> style="@style/ChipFilled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<com.google.android.material.chip.Chip android:nextFocusLeft="@id/home_type_watching_btt"
android:id="@+id/home_type_on_hold_btt" android:nextFocusRight="@id/home_type_on_hold_btt"
style="@style/ChipFilled" android:text="@string/type_plan_to_watch" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:nextFocusLeft="@id/home_plan_to_watch_btt" <com.google.android.material.chip.Chip
android:nextFocusRight="@id/home_type_dropped_btt" android:id="@+id/home_type_on_hold_btt"
android:text="@string/type_on_hold" /> style="@style/ChipFilled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<com.google.android.material.chip.Chip android:nextFocusLeft="@id/home_plan_to_watch_btt"
android:id="@+id/home_type_dropped_btt" android:nextFocusRight="@id/home_type_dropped_btt"
style="@style/ChipFilled" android:text="@string/type_on_hold" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:nextFocusLeft="@id/home_type_on_hold_btt" <com.google.android.material.chip.Chip
android:nextFocusRight="@id/home_type_completed_btt" android:id="@+id/home_type_dropped_btt"
android:text="@string/type_dropped" /> style="@style/ChipFilled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<com.google.android.material.chip.Chip android:nextFocusLeft="@id/home_type_on_hold_btt"
android:id="@+id/home_type_completed_btt" android:nextFocusRight="@id/home_type_completed_btt"
style="@style/ChipFilled" android:text="@string/type_dropped" />
android:layout_width="wrap_content"
android:layout_height="wrap_content" <com.google.android.material.chip.Chip
android:nextFocusLeft="@id/home_type_dropped_btt" android:id="@+id/home_type_completed_btt"
android:text="@string/type_completed" /> style="@style/ChipFilled"
</com.google.android.material.chip.ChipGroup> android:layout_width="wrap_content"
</HorizontalScrollView>
android:layout_height="wrap_content"
android:nextFocusLeft="@id/home_type_dropped_btt"
android:text="@string/type_completed" />
</com.google.android.material.chip.ChipGroup>
</HorizontalScrollView>
<ImageView
android:layout_marginEnd="12dp"
android:layout_gravity="end"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_baseline_arrow_forward_24"
app:drawableTint="?attr/white"
android:contentDescription="@string/home_more_info"/>
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_bookmarked_child_recyclerview" android:id="@+id/home_bookmarked_child_recyclerview"

View file

@ -6,27 +6,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<FrameLayout <TextView
android:foreground="?android:attr/selectableItemBackgroundBorderless" android:id="@+id/home_child_more_info"
android:id="@+id/home_child_more_info" style="@style/WatchHeaderText"
android:padding="12dp" android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content"> android:layout_marginEnd="0dp"
android:padding="12dp"
<TextView tools:text="@string/continue_watching"
android:id="@+id/home_parent_item_title" app:drawableRightCompat="@drawable/ic_baseline_arrow_forward_24"
style="@style/WatchHeaderText" app:drawableTint="?attr/white"
tools:text="Trending" /> android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/home_more_info"/>
<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:nextFocusUp="@id/home_child_more_info" android:nextFocusUp="@id/home_child_more_info"

View file

@ -8,7 +8,7 @@
<TextView <TextView
android:layout_marginStart="@dimen/navbar_width" android:layout_marginStart="@dimen/navbar_width"
android:id="@+id/home_parent_item_title" android:id="@+id/home_child_more_info"
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"