Fix index out of bounds

This commit is contained in:
Blatzar 2022-08-15 16:44:46 +02:00
parent ce45351399
commit cff67b7db3
4 changed files with 9 additions and 10 deletions

View file

@ -92,7 +92,7 @@ object APIHolder {
}
private fun getLoadResponseIdFromUrl(url: String, apiName: String): Int {
return url.replace(getApiFromName(apiName).mainUrl, "").replace("/", "").hashCode()
return url.replace(getApiFromNameNull(apiName)?.mainUrl ?: "", "").replace("/", "").hashCode()
}
fun LoadResponse.getId(): Int {

View file

@ -101,9 +101,7 @@ import kotlinx.coroutines.runBlocking
import android.widget.EditText
import android.widget.AbsListView
import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull
const val START_ACTION_RESUME_LATEST = 1
@ -470,11 +468,11 @@ open class ResultFragment : ResultTrailerPlayer() {
}
syncModel.addFromUrl(url)
val api = getApiFromName(apiName)
val api = getApiFromNameNull(apiName)
result_episodes?.adapter =
EpisodeAdapter(
api.hasDownloadSupport,
api?.hasDownloadSupport == true,
{ episodeClick ->
viewModel.handleAction(activity, episodeClick)
},

View file

@ -197,10 +197,10 @@ class ResultFragmentPhone : ResultFragment() {
}
//result_poster_blur_holder?.translationY = -scrollY.toFloat()
})
val api = APIHolder.getApiFromName(apiName)
val api = APIHolder.getApiFromNameNull(apiName)
if (media_route_button != null) {
val chromecastSupport = api.hasChromecastSupport
val chromecastSupport = api?.hasChromecastSupport == true
media_route_button?.alpha = if (chromecastSupport) 1f else 0.3f
if (!chromecastSupport) {
media_route_button?.setOnClickListener {

View file

@ -23,6 +23,7 @@ import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.APIHolder.filterProviderByPreferredMedia
import com.lagradost.cloudstream3.APIHolder.filterSearchResultByFilmQuality
import com.lagradost.cloudstream3.APIHolder.getApiFromName
import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull
import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings
import com.lagradost.cloudstream3.APIHolder.getApiSettings
import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey
@ -105,11 +106,11 @@ class SearchFragment : Fragment() {
searchViewModel.searchAndCancel(
query = query,
providersActive = selectedApis.filter { name ->
settings.contains(name) && getApiFromName(name).supportedTypes.any {
settings.contains(name) && getApiFromNameNull(name)?.supportedTypes?.any {
selectedSearchTypes.contains(
it
)
}
} == true
}.toSet()
)
}