mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Fix ResultTrailerPlayer and DownloadedPlayerActivity
This commit is contained in:
parent
1881be24fc
commit
168b3959c4
3 changed files with 33 additions and 19 deletions
|
@ -6,6 +6,7 @@ import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.lagradost.cloudstream3.CommonActivity
|
import com.lagradost.cloudstream3.CommonActivity
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
|
@ -34,10 +35,6 @@ class DownloadedPlayerActivity : AppCompatActivity() {
|
||||||
CommonActivity.onUserLeaveHint(this)
|
CommonActivity.onUserLeaveHint(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun playLink(url: String) {
|
private fun playLink(url: String) {
|
||||||
this.navigate(
|
this.navigate(
|
||||||
R.id.global_to_navigation_player, GeneratorPlayer.newInstance(
|
R.id.global_to_navigation_player, GeneratorPlayer.newInstance(
|
||||||
|
@ -109,6 +106,15 @@ class DownloadedPlayerActivity : AppCompatActivity() {
|
||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onBackPressedDispatcher.addCallback(
|
||||||
|
this,
|
||||||
|
object : OnBackPressedCallback(true) {
|
||||||
|
override fun handleOnBackPressed() {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.lagradost.cloudstream3.CommonActivity.screenHeight
|
import com.lagradost.cloudstream3.CommonActivity.screenHeight
|
||||||
|
@ -15,10 +16,8 @@ import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.ui.player.CSPlayerEvent
|
import com.lagradost.cloudstream3.ui.player.CSPlayerEvent
|
||||||
import com.lagradost.cloudstream3.ui.player.PlayerEventSource
|
import com.lagradost.cloudstream3.ui.player.PlayerEventSource
|
||||||
import com.lagradost.cloudstream3.ui.player.SubtitleData
|
import com.lagradost.cloudstream3.ui.player.SubtitleData
|
||||||
import com.lagradost.cloudstream3.utils.IOnBackPressed
|
|
||||||
|
|
||||||
|
open class ResultTrailerPlayer : ResultFragmentPhone() {
|
||||||
open class ResultTrailerPlayer : ResultFragmentPhone(), IOnBackPressed {
|
|
||||||
|
|
||||||
override var lockRotation = false
|
override var lockRotation = false
|
||||||
override var isFullScreenPlayer = false
|
override var isFullScreenPlayer = false
|
||||||
|
@ -28,7 +27,7 @@ open class ResultTrailerPlayer : ResultFragmentPhone(), IOnBackPressed {
|
||||||
const val TAG = "RESULT_TRAILER"
|
const val TAG = "RESULT_TRAILER"
|
||||||
}
|
}
|
||||||
|
|
||||||
var playerWidthHeight: Pair<Int, Int>? = null
|
private var playerWidthHeight: Pair<Int, Int>? = null
|
||||||
|
|
||||||
override fun nextEpisode() {}
|
override fun nextEpisode() {}
|
||||||
|
|
||||||
|
@ -154,6 +153,10 @@ open class ResultTrailerPlayer : ResultFragmentPhone(), IOnBackPressed {
|
||||||
}
|
}
|
||||||
fixPlayerSize()
|
fixPlayerSize()
|
||||||
uiReset()
|
uiReset()
|
||||||
|
|
||||||
|
if (isFullScreenPlayer) {
|
||||||
|
attachBackPressedCallback()
|
||||||
|
} else detachBackPressedCallback()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
@ -172,12 +175,22 @@ open class ResultTrailerPlayer : ResultFragmentPhone(), IOnBackPressed {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed(): Boolean {
|
private var backPressedCallback: OnBackPressedCallback? = null
|
||||||
return if (isFullScreenPlayer) {
|
|
||||||
updateFullscreen(false)
|
private fun attachBackPressedCallback() {
|
||||||
false
|
if (backPressedCallback == null) {
|
||||||
} else {
|
backPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
true
|
override fun handleOnBackPressed() {
|
||||||
|
updateFullscreen(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backPressedCallback?.isEnabled = true
|
||||||
|
requireActivity().onBackPressedDispatcher.addCallback(requireActivity(), backPressedCallback!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun detachBackPressedCallback() {
|
||||||
|
backPressedCallback?.isEnabled = false
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +0,0 @@
|
||||||
package com.lagradost.cloudstream3.utils
|
|
||||||
|
|
||||||
interface IOnBackPressed {
|
|
||||||
fun onBackPressed(): Boolean
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue