mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
parent
61d63b17d8
commit
8f6e8a8e99
3 changed files with 34 additions and 24 deletions
|
@ -231,7 +231,7 @@ dependencies {
|
||||||
// API because cba maintaining it myself
|
// API because cba maintaining it myself
|
||||||
implementation("com.uwetrottmann.tmdb2:tmdb-java:2.6.0")
|
implementation("com.uwetrottmann.tmdb2:tmdb-java:2.6.0")
|
||||||
|
|
||||||
implementation("com.github.discord:OverlappingPanels:0.1.3")
|
implementation("com.github.discord:OverlappingPanels:0.1.5")
|
||||||
// debugImplementation because LeakCanary should only run in debug builds.
|
// debugImplementation because LeakCanary should only run in debug builds.
|
||||||
//debugImplementation("com.squareup.leakcanary:leakcanary-android:2.12")
|
//debugImplementation("com.squareup.leakcanary:leakcanary-android:2.12")
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import com.discord.panels.OverlappingPanelsLayout
|
import com.discord.panels.OverlappingPanelsLayout
|
||||||
import com.discord.panels.PanelsChildGestureRegionObserver
|
import com.discord.panels.PanelsChildGestureRegionObserver
|
||||||
import com.google.android.gms.cast.framework.CastButtonFactory
|
import com.google.android.gms.cast.framework.CastButtonFactory
|
||||||
|
@ -62,8 +61,6 @@ import com.lagradost.cloudstream3.ui.search.SearchHelper
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
|
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.html
|
import com.lagradost.cloudstream3.utils.AppUtils.html
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable
|
import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.isLtr
|
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.isRtl
|
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.loadCache
|
import com.lagradost.cloudstream3.utils.AppUtils.loadCache
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.openBrowser
|
import com.lagradost.cloudstream3.utils.AppUtils.openBrowser
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
|
@ -81,8 +78,13 @@ import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
||||||
import com.lagradost.cloudstream3.utils.VideoDownloadHelper
|
import com.lagradost.cloudstream3.utils.VideoDownloadHelper
|
||||||
|
|
||||||
|
|
||||||
open class ResultFragmentPhone : FullScreenPlayer(),
|
open class ResultFragmentPhone : FullScreenPlayer() {
|
||||||
PanelsChildGestureRegionObserver.GestureRegionsListener {
|
private val gestureRegionsListener = object : PanelsChildGestureRegionObserver.GestureRegionsListener {
|
||||||
|
override fun onGestureRegionsUpdate(gestureRegions: List<Rect>) {
|
||||||
|
binding?.resultOverlappingPanels?.setChildGestureRegions(gestureRegions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected lateinit var viewModel: ResultViewModel2
|
protected lateinit var viewModel: ResultViewModel2
|
||||||
protected lateinit var syncModel: SyncViewModel
|
protected lateinit var syncModel: SyncViewModel
|
||||||
|
|
||||||
|
@ -210,15 +212,20 @@ open class ResultFragmentPhone : FullScreenPlayer(),
|
||||||
loadTrailer()
|
loadTrailer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
PanelsChildGestureRegionObserver.Provider.get().apply {
|
||||||
|
resultBinding?.resultCastItems?.let {
|
||||||
|
unregister(it)
|
||||||
|
}
|
||||||
|
removeGestureRegionsUpdateListener(gestureRegionsListener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
//somehow this still leaks and I dont know why????
|
//somehow this still leaks and I dont know why????
|
||||||
// todo look at https://github.com/discord/OverlappingPanels/blob/70b4a7cf43c6771873b1e091029d332896d41a1a/sample_app/src/main/java/com/discord/sampleapp/MainActivity.kt
|
// todo look at https://github.com/discord/OverlappingPanels/blob/70b4a7cf43c6771873b1e091029d332896d41a1a/sample_app/src/main/java/com/discord/sampleapp/MainActivity.kt
|
||||||
PanelsChildGestureRegionObserver.Provider.get().let { obs ->
|
|
||||||
resultBinding?.resultCastItems?.let {
|
|
||||||
obs.unregister(it)
|
|
||||||
}
|
|
||||||
obs.removeGestureRegionsUpdateListener(this)
|
|
||||||
}
|
|
||||||
updateUIEvent -= ::updateUI
|
updateUIEvent -= ::updateUI
|
||||||
binding = null
|
binding = null
|
||||||
resultBinding = null
|
resultBinding = null
|
||||||
|
@ -287,6 +294,8 @@ open class ResultFragmentPhone : FullScreenPlayer(),
|
||||||
it.colorFromAttribute(R.attr.primaryBlackBackground)
|
it.colorFromAttribute(R.attr.primaryBlackBackground)
|
||||||
}
|
}
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
PanelsChildGestureRegionObserver.Provider.get()
|
||||||
|
.addGestureRegionsUpdateListener(gestureRegionsListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
@ -323,7 +332,16 @@ open class ResultFragmentPhone : FullScreenPlayer(),
|
||||||
setUrl(storedData.url)
|
setUrl(storedData.url)
|
||||||
syncModel.addFromUrl(storedData.url)
|
syncModel.addFromUrl(storedData.url)
|
||||||
val api = APIHolder.getApiFromNameNull(storedData.apiName)
|
val api = APIHolder.getApiFromNameNull(storedData.apiName)
|
||||||
PanelsChildGestureRegionObserver.Provider.get().addGestureRegionsUpdateListener(this)
|
|
||||||
|
PanelsChildGestureRegionObserver.Provider.get().apply {
|
||||||
|
resultBinding?.resultCastItems?.let {
|
||||||
|
register(it)
|
||||||
|
}
|
||||||
|
addGestureRegionsUpdateListener(gestureRegionsListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ===== ===== =====
|
// ===== ===== =====
|
||||||
|
|
||||||
resultBinding?.apply {
|
resultBinding?.apply {
|
||||||
|
@ -374,9 +392,8 @@ open class ResultFragmentPhone : FullScreenPlayer(),
|
||||||
DownloadButtonSetup.handleDownloadClick(downloadClickEvent)
|
DownloadButtonSetup.handleDownloadClick(downloadClickEvent)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
resultCastItems.let {
|
|
||||||
PanelsChildGestureRegionObserver.Provider.get().register(it)
|
|
||||||
}
|
|
||||||
resultScroll.setOnScrollChangeListener(NestedScrollView.OnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
|
resultScroll.setOnScrollChangeListener(NestedScrollView.OnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
|
||||||
val dy = scrollY - oldScrollY
|
val dy = scrollY - oldScrollY
|
||||||
if (dy > 0) { //check for scroll down
|
if (dy > 0) { //check for scroll down
|
||||||
|
@ -1055,11 +1072,7 @@ open class ResultFragmentPhone : FullScreenPlayer(),
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
PanelsChildGestureRegionObserver.Provider.get().addGestureRegionsUpdateListener(this)
|
PanelsChildGestureRegionObserver.Provider.get().addGestureRegionsUpdateListener(gestureRegionsListener)
|
||||||
}
|
|
||||||
|
|
||||||
override fun onGestureRegionsUpdate(gestureRegions: List<Rect>) {
|
|
||||||
binding?.resultOverlappingPanels?.setChildGestureRegions(gestureRegions)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setRecommendations(rec: List<SearchResponse>?, validApiName: String?) {
|
private fun setRecommendations(rec: List<SearchResponse>?, validApiName: String?) {
|
||||||
|
|
|
@ -118,9 +118,6 @@ open class ResultTrailerPlayer : ResultFragmentPhone(), IOnBackPressed {
|
||||||
override fun onTracksInfoChanged() {}
|
override fun onTracksInfoChanged() {}
|
||||||
|
|
||||||
override fun exitedPipMode() {}
|
override fun exitedPipMode() {}
|
||||||
|
|
||||||
override fun onGestureRegionsUpdate(gestureRegions: List<Rect>) {}
|
|
||||||
|
|
||||||
private fun updateFullscreen(fullscreen: Boolean) {
|
private fun updateFullscreen(fullscreen: Boolean) {
|
||||||
isFullScreenPlayer = fullscreen
|
isFullScreenPlayer = fullscreen
|
||||||
lockRotation = fullscreen
|
lockRotation = fullscreen
|
||||||
|
|
Loading…
Reference in a new issue