mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
crash issue fix
This commit is contained in:
parent
c0f8d8438a
commit
d49384a4cd
2 changed files with 31 additions and 20 deletions
|
@ -21,7 +21,6 @@ import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.*
|
import android.view.View.*
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
|
||||||
import android.view.animation.AccelerateInterpolator
|
import android.view.animation.AccelerateInterpolator
|
||||||
import android.view.animation.AlphaAnimation
|
import android.view.animation.AlphaAnimation
|
||||||
import android.view.animation.Animation
|
import android.view.animation.Animation
|
||||||
|
@ -2037,11 +2036,14 @@ class PlayerFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun preferedQuality(tempCurrentUrls: List<ExtractorLink>?): Int? {
|
private fun preferredQuality(tempCurrentUrls: List<ExtractorLink>?): Int? {
|
||||||
if (tempCurrentUrls.isNullOrEmpty()) return null
|
if (tempCurrentUrls.isNullOrEmpty()) return null
|
||||||
val sortedUrls = sortUrls(tempCurrentUrls).reversed()
|
val sortedUrls = sortUrls(tempCurrentUrls).reversed()
|
||||||
val currentQuality =
|
var currentQuality = Qualities.values().last().value
|
||||||
settingsManager.getInt(getString(R.string.watch_quality_pref), Qualities.values().last().value)
|
context?.let { ctx ->
|
||||||
|
if (this::settingsManager.isInitialized)
|
||||||
|
currentQuality = settingsManager.getInt(ctx.getString(R.string.watch_quality_pref), currentQuality)
|
||||||
|
}
|
||||||
|
|
||||||
var currentId = sortedUrls.first().getId() // lowest quality
|
var currentId = sortedUrls.first().getId() // lowest quality
|
||||||
for (url in sortedUrls) {
|
for (url in sortedUrls) {
|
||||||
|
@ -2061,8 +2063,7 @@ class PlayerFragment : Fragment() {
|
||||||
view?.setOnTouchListener { _, _ -> return@setOnTouchListener true } // VERY IMPORTANT https://stackoverflow.com/questions/28818926/prevent-clicking-on-a-button-in-an-activity-while-showing-a-fragment
|
view?.setOnTouchListener { _, _ -> return@setOnTouchListener true } // VERY IMPORTANT https://stackoverflow.com/questions/28818926/prevent-clicking-on-a-button-in-an-activity-while-showing-a-fragment
|
||||||
val tempCurrentUrls = getUrls()
|
val tempCurrentUrls = getUrls()
|
||||||
if (tempCurrentUrls != null) {
|
if (tempCurrentUrls != null) {
|
||||||
setMirrorId(preferedQuality(tempCurrentUrls))
|
setMirrorId(preferredQuality(tempCurrentUrls))
|
||||||
//setMirrorId(sortedUrls.first().getId()) // BECAUSE URLS CANT BE REORDERED
|
|
||||||
}
|
}
|
||||||
val tempUrl = getCurrentUrl()
|
val tempUrl = getCurrentUrl()
|
||||||
println("TEMP:" + tempUrl?.name)
|
println("TEMP:" + tempUrl?.name)
|
||||||
|
@ -2074,7 +2075,7 @@ class PlayerFragment : Fragment() {
|
||||||
val currentUrls = getUrls()
|
val currentUrls = getUrls()
|
||||||
if (currentUrls != null && currentUrls.isNotEmpty()) {
|
if (currentUrls != null && currentUrls.isNotEmpty()) {
|
||||||
if (!isCurrentlyPlaying) {
|
if (!isCurrentlyPlaying) {
|
||||||
setMirrorId(preferedQuality(currentUrls))
|
setMirrorId(preferredQuality(currentUrls))
|
||||||
initPlayer(getCurrentUrl())
|
initPlayer(getCurrentUrl())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2085,19 +2086,6 @@ class PlayerFragment : Fragment() {
|
||||||
} else {
|
} else {
|
||||||
initPlayer(tempUrl)
|
initPlayer(tempUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
val currentUrl = tempUrl
|
|
||||||
if (currentUrl == null) {
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
Toast.makeText(activity, "Error getting link", LENGTH_LONG).show()
|
|
||||||
//MainActivity.popCurrentPage()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//isLoadingNextEpisode = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.lagradost.cloudstream3.utils
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import dalvik.system.PathClassLoader
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
class ExtensionManager {
|
||||||
|
interface TestSource {
|
||||||
|
fun doMath(): Int
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSourceFromDex(context: Context, pkgName: String, file: File): TestSource? {
|
||||||
|
val loader = PathClassLoader(file.absolutePath, null, context.classLoader)
|
||||||
|
var source: TestSource? = null
|
||||||
|
|
||||||
|
source = when (val obj = Class.forName(pkgName, false, loader).newInstance()) {
|
||||||
|
is TestSource -> obj
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
|
return source
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue