mirror of
				https://github.com/recloudstream/cloudstream.git
				synced 2024-08-15 01:53:11 +00:00 
			
		
		
		
	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 = | ||||
|             ArrayList<AnimeEpisode>( | ||||
|                 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>()) | ||||
|         val status = when (data.status) { | ||||
|             "current" -> ShowStatus.Ongoing | ||||
|  |  | |||
|  | @ -574,7 +574,7 @@ class ResultFragment : Fragment() { | |||
|                         val subs = currentSubs | ||||
| 
 | ||||
|                         val outputDir = requireContext().cacheDir | ||||
|                         val outputFile = withContext(Dispatchers.IO)  { | ||||
|                         val outputFile = withContext(Dispatchers.IO) { | ||||
|                             File.createTempFile("mirrorlist", ".m3u8", outputDir) | ||||
|                         } | ||||
|                         var text = "#EXTM3U" | ||||
|  | @ -738,11 +738,9 @@ class ResultFragment : Fragment() { | |||
|         observe(viewModel.publicEpisodes) { episodes -> | ||||
|             if (result_episodes == null || result_episodes.adapter == null) return@observe | ||||
|             currentEpisodes = episodes | ||||
|             activity?.runOnUiThread { | ||||
|                 (result_episodes.adapter as EpisodeAdapter).cardList = episodes | ||||
|                 (result_episodes.adapter as EpisodeAdapter).updateLayout() | ||||
|                 (result_episodes.adapter as EpisodeAdapter).notifyDataSetChanged() | ||||
|             } | ||||
|             (result_episodes?.adapter as EpisodeAdapter?)?.cardList = episodes | ||||
|             (result_episodes?.adapter as EpisodeAdapter?)?.updateLayout() | ||||
|             (result_episodes?.adapter as EpisodeAdapter?)?.notifyDataSetChanged() | ||||
|         } | ||||
| 
 | ||||
|         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.setResultWatchState | ||||
| import com.lagradost.cloudstream3.utils.ExtractorLink | ||||
| import kotlinx.coroutines.Dispatchers | ||||
| import kotlinx.coroutines.launch | ||||
| import kotlinx.coroutines.withContext | ||||
| 
 | ||||
| const val EPISODE_RANGE_SIZE = 50 | ||||
| const val EPISODE_RANGE_OVERLOAD = 60 | ||||
|  | @ -50,28 +52,31 @@ class ResultViewModel : ViewModel() { | |||
|     private val _watchStatus: MutableLiveData<WatchType> = MutableLiveData() | ||||
|     val watchStatus: LiveData<WatchType> get() = _watchStatus | ||||
| 
 | ||||
|     fun updateWatchStatus(context: Context, status: WatchType) { | ||||
|         val currentId = id.value ?: return | ||||
|     fun updateWatchStatus(context: Context, status: WatchType) = viewModelScope.launch { | ||||
|         val currentId = id.value ?: return@launch | ||||
|         _watchStatus.postValue(status) | ||||
|         context.setResultWatchState(currentId, status.internalId) | ||||
|         val resultPage = page.value | ||||
|         if (resultPage != null) { | ||||
|             val current = context.getBookmarkedData(currentId) | ||||
|             val currentTime = System.currentTimeMillis() | ||||
|             context.setBookmarkedData( | ||||
|                 currentId, | ||||
|                 DataStoreHelper.BookmarkedData( | ||||
| 
 | ||||
|         withContext(Dispatchers.IO) { | ||||
|             context.setResultWatchState(currentId, status.internalId) | ||||
|             if (resultPage != null) { | ||||
|                 val current = context.getBookmarkedData(currentId) | ||||
|                 val currentTime = System.currentTimeMillis() | ||||
|                 context.setBookmarkedData( | ||||
|                     currentId, | ||||
|                     current?.bookmarkedTime ?: currentTime, | ||||
|                     currentTime, | ||||
|                     resultPage.name, | ||||
|                     resultPage.url, | ||||
|                     resultPage.apiName, | ||||
|                     resultPage.type, | ||||
|                     resultPage.posterUrl, | ||||
|                     resultPage.year | ||||
|                     DataStoreHelper.BookmarkedData( | ||||
|                         currentId, | ||||
|                         current?.bookmarkedTime ?: currentTime, | ||||
|                         currentTime, | ||||
|                         resultPage.name, | ||||
|                         resultPage.url, | ||||
|                         resultPage.apiName, | ||||
|                         resultPage.type, | ||||
|                         resultPage.posterUrl, | ||||
|                         resultPage.year | ||||
|                     ) | ||||
|                 ) | ||||
|             ) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | @ -91,7 +96,12 @@ class ResultViewModel : ViewModel() { | |||
|         } | ||||
|         val seasons = seasonTypes.toList().map { it.first } | ||||
|         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 | ||||
| 
 | ||||
|         if (internalId != null) context.setResultSeason(internalId, realSelection) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue