forked from recloudstream/cloudstream
hopefully fixed crash issue
This commit is contained in:
parent
5523d6539a
commit
938a8e2a18
3 changed files with 35 additions and 26 deletions
|
@ -273,7 +273,8 @@ class ShiroProvider : MainAPI() {
|
||||||
val episodes =
|
val episodes =
|
||||||
ArrayList<AnimeEpisode>(
|
ArrayList<AnimeEpisode>(
|
||||||
data.episodes?.distinctBy { it.episode_number }?.sortedBy { it.episode_number }
|
data.episodes?.distinctBy { it.episode_number }?.sortedBy { it.episode_number }
|
||||||
?.map { AnimeEpisode(it.videos[0].video_id) }
|
?.filter { it.videos.isNotEmpty() }
|
||||||
|
?.map { AnimeEpisode(it.videos.first().video_id) }
|
||||||
?: ArrayList<AnimeEpisode>())
|
?: ArrayList<AnimeEpisode>())
|
||||||
val status = when (data.status) {
|
val status = when (data.status) {
|
||||||
"current" -> ShowStatus.Ongoing
|
"current" -> ShowStatus.Ongoing
|
||||||
|
|
|
@ -738,11 +738,9 @@ class ResultFragment : Fragment() {
|
||||||
observe(viewModel.publicEpisodes) { episodes ->
|
observe(viewModel.publicEpisodes) { episodes ->
|
||||||
if (result_episodes == null || result_episodes.adapter == null) return@observe
|
if (result_episodes == null || result_episodes.adapter == null) return@observe
|
||||||
currentEpisodes = episodes
|
currentEpisodes = episodes
|
||||||
activity?.runOnUiThread {
|
(result_episodes?.adapter as EpisodeAdapter?)?.cardList = episodes
|
||||||
(result_episodes.adapter as EpisodeAdapter).cardList = episodes
|
(result_episodes?.adapter as EpisodeAdapter?)?.updateLayout()
|
||||||
(result_episodes.adapter as EpisodeAdapter).updateLayout()
|
(result_episodes?.adapter as EpisodeAdapter?)?.notifyDataSetChanged()
|
||||||
(result_episodes.adapter as EpisodeAdapter).notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
observe(viewModel.selectedRange) { range ->
|
observe(viewModel.selectedRange) { range ->
|
||||||
|
|
|
@ -18,7 +18,9 @@ import com.lagradost.cloudstream3.utils.DataStoreHelper.setBookmarkedData
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.setResultSeason
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.setResultSeason
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.setResultWatchState
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.setResultWatchState
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
const val EPISODE_RANGE_SIZE = 50
|
const val EPISODE_RANGE_SIZE = 50
|
||||||
const val EPISODE_RANGE_OVERLOAD = 60
|
const val EPISODE_RANGE_OVERLOAD = 60
|
||||||
|
@ -50,11 +52,13 @@ class ResultViewModel : ViewModel() {
|
||||||
private val _watchStatus: MutableLiveData<WatchType> = MutableLiveData()
|
private val _watchStatus: MutableLiveData<WatchType> = MutableLiveData()
|
||||||
val watchStatus: LiveData<WatchType> get() = _watchStatus
|
val watchStatus: LiveData<WatchType> get() = _watchStatus
|
||||||
|
|
||||||
fun updateWatchStatus(context: Context, status: WatchType) {
|
fun updateWatchStatus(context: Context, status: WatchType) = viewModelScope.launch {
|
||||||
val currentId = id.value ?: return
|
val currentId = id.value ?: return@launch
|
||||||
_watchStatus.postValue(status)
|
_watchStatus.postValue(status)
|
||||||
context.setResultWatchState(currentId, status.internalId)
|
|
||||||
val resultPage = page.value
|
val resultPage = page.value
|
||||||
|
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
context.setResultWatchState(currentId, status.internalId)
|
||||||
if (resultPage != null) {
|
if (resultPage != null) {
|
||||||
val current = context.getBookmarkedData(currentId)
|
val current = context.getBookmarkedData(currentId)
|
||||||
val currentTime = System.currentTimeMillis()
|
val currentTime = System.currentTimeMillis()
|
||||||
|
@ -74,6 +78,7 @@ class ResultViewModel : ViewModel() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun loadWatchStatus(context: Context, localId: Int? = null) {
|
private fun loadWatchStatus(context: Context, localId: Int? = null) {
|
||||||
val currentId = localId ?: id.value ?: return
|
val currentId = localId ?: id.value ?: return
|
||||||
|
@ -91,7 +96,12 @@ class ResultViewModel : ViewModel() {
|
||||||
}
|
}
|
||||||
val seasons = seasonTypes.toList().map { it.first }
|
val seasons = seasonTypes.toList().map { it.first }
|
||||||
seasonSelections.postValue(seasons)
|
seasonSelections.postValue(seasons)
|
||||||
val realSelection = if (!seasonTypes.containsKey(selection)) seasons[0] else selection
|
if(seasons.isEmpty()) { // WHAT THE FUCK DID YOU DO????? HOW DID YOU DO THIS
|
||||||
|
_publicEpisodes.postValue(ArrayList())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val realSelection = if (!seasonTypes.containsKey(selection)) seasons.first() else selection
|
||||||
val internalId = id.value
|
val internalId = id.value
|
||||||
|
|
||||||
if (internalId != null) context.setResultSeason(internalId, realSelection)
|
if (internalId != null) context.setResultSeason(internalId, realSelection)
|
||||||
|
|
Loading…
Reference in a new issue