forked from recloudstream/cloudstream
fixed small crash issue
This commit is contained in:
parent
1d7a74324b
commit
9b94853199
5 changed files with 84 additions and 61 deletions
|
@ -560,13 +560,14 @@ class GeneratorPlayer : FullScreenPlayer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Generate video title
|
//Generate video title
|
||||||
|
context?.let { ctx ->
|
||||||
var playerVideoTitle = if (headerName != null) {
|
var playerVideoTitle = if (headerName != null) {
|
||||||
(headerName +
|
(headerName +
|
||||||
if (tvType.isEpisodeBased() && episode != null)
|
if (tvType.isEpisodeBased() && episode != null)
|
||||||
if (season == null)
|
if (season == null)
|
||||||
" - ${getString(R.string.episode)} $episode"
|
" - ${ctx.getString(R.string.episode)} $episode"
|
||||||
else
|
else
|
||||||
" \"${getString(R.string.season_short)}${season}:${getString(R.string.episode_short)}${episode}\""
|
" \"${ctx.getString(R.string.season_short)}${season}:${ctx.getString(R.string.episode_short)}${episode}\""
|
||||||
else "") + if (subName.isNullOrBlank() || subName == headerName) "" else " - $subName"
|
else "") + if (subName.isNullOrBlank() || subName == headerName) "" else " - $subName"
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
|
@ -588,6 +589,8 @@ class GeneratorPlayer : FullScreenPlayer() {
|
||||||
player_video_title?.text = playerVideoTitle
|
player_video_title?.text = playerVideoTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
fun setPlayerDimen(widthHeight: Pair<Int, Int>?) {
|
fun setPlayerDimen(widthHeight: Pair<Int, Int>?) {
|
||||||
val extra = if (widthHeight != null) {
|
val extra = if (widthHeight != null) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.lagradost.cloudstream3.ui.search
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.lagradost.cloudstream3.CommonActivity.showToast
|
import com.lagradost.cloudstream3.CommonActivity.showToast
|
||||||
|
import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_PLAY_FILE
|
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_PLAY_FILE
|
||||||
import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick
|
import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick
|
||||||
import com.lagradost.cloudstream3.ui.download.DownloadClickEvent
|
import com.lagradost.cloudstream3.ui.download.DownloadClickEvent
|
||||||
|
@ -20,6 +21,10 @@ object SearchHelper {
|
||||||
}
|
}
|
||||||
SEARCH_ACTION_PLAY_FILE -> {
|
SEARCH_ACTION_PLAY_FILE -> {
|
||||||
if (card is DataStoreHelper.ResumeWatchingResult) {
|
if (card is DataStoreHelper.ResumeWatchingResult) {
|
||||||
|
val id = card.id
|
||||||
|
if(id == null) {
|
||||||
|
showToast(activity, R.string.error_invalid_id, Toast.LENGTH_SHORT)
|
||||||
|
} else {
|
||||||
if (card.isFromDownload) {
|
if (card.isFromDownload) {
|
||||||
handleDownloadClick(
|
handleDownloadClick(
|
||||||
activity, card.name, DownloadClickEvent(
|
activity, card.name, DownloadClickEvent(
|
||||||
|
@ -29,7 +34,7 @@ object SearchHelper {
|
||||||
card.posterUrl,
|
card.posterUrl,
|
||||||
card.episode ?: 0,
|
card.episode ?: 0,
|
||||||
card.season,
|
card.season,
|
||||||
card.id!!,
|
id,
|
||||||
card.parentId ?: return,
|
card.parentId ?: return,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
@ -38,8 +43,10 @@ object SearchHelper {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
activity.loadSearchResult(card, START_ACTION_LOAD_EP, card.id)
|
activity.loadSearchResult(card, START_ACTION_LOAD_EP, id)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
handleSearchClickCallback(
|
handleSearchClickCallback(
|
||||||
activity,
|
activity,
|
||||||
|
|
|
@ -6,6 +6,7 @@ import androidx.preference.PreferenceManager
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||||
import com.fasterxml.jackson.databind.json.JsonMapper
|
import com.fasterxml.jackson.databind.json.JsonMapper
|
||||||
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
||||||
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
|
|
||||||
const val DOWNLOAD_HEADER_CACHE = "download_header_cache"
|
const val DOWNLOAD_HEADER_CACHE = "download_header_cache"
|
||||||
|
|
||||||
|
@ -13,9 +14,8 @@ const val DOWNLOAD_HEADER_CACHE = "download_header_cache"
|
||||||
const val DOWNLOAD_EPISODE_CACHE = "download_episode_cache"
|
const val DOWNLOAD_EPISODE_CACHE = "download_episode_cache"
|
||||||
const val VIDEO_PLAYER_BRIGHTNESS = "video_player_alpha_key"
|
const val VIDEO_PLAYER_BRIGHTNESS = "video_player_alpha_key"
|
||||||
const val HOMEPAGE_API = "home_api_used"
|
const val HOMEPAGE_API = "home_api_used"
|
||||||
const val SEARCH_PROVIDER_TOGGLE = "settings_providers_toggle"
|
|
||||||
|
|
||||||
const val PREFERENCES_NAME: String = "rebuild_preference"
|
const val PREFERENCES_NAME = "rebuild_preference"
|
||||||
|
|
||||||
object DataStore {
|
object DataStore {
|
||||||
val mapper: JsonMapper = JsonMapper.builder().addModule(KotlinModule())
|
val mapper: JsonMapper = JsonMapper.builder().addModule(KotlinModule())
|
||||||
|
@ -34,6 +34,7 @@ object DataStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> Context.setKeyRaw(path: String, value: T, isEditingAppSettings: Boolean = false) {
|
fun <T> Context.setKeyRaw(path: String, value: T, isEditingAppSettings: Boolean = false) {
|
||||||
|
try {
|
||||||
val editor: SharedPreferences.Editor =
|
val editor: SharedPreferences.Editor =
|
||||||
if (isEditingAppSettings) getDefaultSharedPrefs().edit() else getSharedPrefs().edit()
|
if (isEditingAppSettings) getDefaultSharedPrefs().edit() else getSharedPrefs().edit()
|
||||||
when (value) {
|
when (value) {
|
||||||
|
@ -45,6 +46,9 @@ object DataStore {
|
||||||
(value as? Set<String> != null) -> editor.putStringSet(path, value as Set<String>)
|
(value as? Set<String> != null) -> editor.putStringSet(path, value as Set<String>)
|
||||||
}
|
}
|
||||||
editor.apply()
|
editor.apply()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logError(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.getDefaultSharedPrefs(): SharedPreferences {
|
fun Context.getDefaultSharedPrefs(): SharedPreferences {
|
||||||
|
@ -69,12 +73,16 @@ object DataStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.removeKey(path: String) {
|
fun Context.removeKey(path: String) {
|
||||||
|
try {
|
||||||
val prefs = getSharedPrefs()
|
val prefs = getSharedPrefs()
|
||||||
if (prefs.contains(path)) {
|
if (prefs.contains(path)) {
|
||||||
val editor: SharedPreferences.Editor = prefs.edit()
|
val editor: SharedPreferences.Editor = prefs.edit()
|
||||||
editor.remove(path)
|
editor.remove(path)
|
||||||
editor.apply()
|
editor.apply()
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logError(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.removeKeys(folder: String): Int {
|
fun Context.removeKeys(folder: String): Int {
|
||||||
|
@ -86,9 +94,13 @@ object DataStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> Context.setKey(path: String, value: T) {
|
fun <T> Context.setKey(path: String, value: T) {
|
||||||
|
try {
|
||||||
val editor: SharedPreferences.Editor = getSharedPrefs().edit()
|
val editor: SharedPreferences.Editor = getSharedPrefs().edit()
|
||||||
editor.putString(path, mapper.writeValueAsString(value))
|
editor.putString(path, mapper.writeValueAsString(value))
|
||||||
editor.apply()
|
editor.apply()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logError(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> Context.setKey(folder: String, path: String, value: T) {
|
fun <T> Context.setKey(folder: String, path: String, value: T) {
|
||||||
|
|
|
@ -132,7 +132,7 @@ object DataStoreHelper {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun removeLastWatchedOld(parentId: Int?) {
|
private fun removeLastWatchedOld(parentId: Int?) {
|
||||||
if (parentId == null) return
|
if (parentId == null) return
|
||||||
removeKey("$currentAccount/$RESULT_RESUME_WATCHING_OLD", parentId.toString())
|
removeKey("$currentAccount/$RESULT_RESUME_WATCHING_OLD", parentId.toString())
|
||||||
}
|
}
|
||||||
|
|
|
@ -520,4 +520,5 @@
|
||||||
<string name="resolution_and_title">Resolution and title</string>
|
<string name="resolution_and_title">Resolution and title</string>
|
||||||
<string name="title">Title</string>
|
<string name="title">Title</string>
|
||||||
<string name="resolution">Resolution</string>
|
<string name="resolution">Resolution</string>
|
||||||
|
<string name="error_invalid_id">Invalid id</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue