minor crash fixes

This commit is contained in:
LagradOst 2021-10-11 00:25:49 +02:00
parent 5048bc5368
commit ee09f604b8
2 changed files with 16 additions and 8 deletions

View file

@ -20,6 +20,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.APIHolder.apis
import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.mvvm.observe
import com.lagradost.cloudstream3.ui.APIRepository.Companion.noneApi
import com.lagradost.cloudstream3.ui.APIRepository.Companion.randomApi
@ -255,7 +256,14 @@ class HomeFragment : Fragment() {
currentHomePage = d
(home_master_recycler?.adapter as ParentItemAdapter?)?.items =
d.items.map { HomePageList(it.name, it.list.filterSearchResponse()) }
d.items.mapNotNull {
try {
HomePageList(it.name, it.list.filterSearchResponse())
} catch (e : Exception) {
logError(e)
null
}
}
home_master_recycler?.adapter?.notifyDataSetChanged()
currentMainList.clear()

View file

@ -1274,7 +1274,7 @@ class PlayerFragment : Fragment() {
fastForward()
}
overlay_loading_skip_button.setOnClickListener {
overlay_loading_skip_button?.setOnClickListener {
setMirrorId(
sortUrls(getUrls() ?: return@setOnClickListener).first()
.getId()
@ -1697,7 +1697,7 @@ class PlayerFragment : Fragment() {
arguments?.putBoolean(STATE_PLAYER_PLAYING, isPlayerPlaying)
arguments?.putInt(RESIZE_MODE_KEY, resizeMode)
arguments?.putFloat(PLAYBACK_SPEED, playbackSpeed)
if (!isDownloadedFile) {
if (!isDownloadedFile && this::playerData.isInitialized) {
arguments?.putString("data", mapper.writeValueAsString(playerData))
}
}
@ -1713,7 +1713,7 @@ class PlayerFragment : Fragment() {
outState.putBoolean(STATE_PLAYER_PLAYING, isPlayerPlaying)
outState.putInt(RESIZE_MODE_KEY, resizeMode)
outState.putFloat(PLAYBACK_SPEED, playbackSpeed)
if (!isDownloadedFile) {
if (!isDownloadedFile && this::playerData.isInitialized) {
outState.putString("data", mapper.writeValueAsString(playerData))
}
super.onSaveInstanceState(outState)
@ -1901,15 +1901,15 @@ class PlayerFragment : Fragment() {
override fun onAnimationRepeat(animation: Animation?) {}
override fun onAnimationEnd(animation: Animation?) {
loading_overlay.post { video_go_back_holder_holder.visibility = GONE; }
loading_overlay?.post { video_go_back_holder_holder?.visibility = GONE; }
}
})
overlay_loading_skip_button.visibility = GONE
overlay_loading_skip_button?.visibility = GONE
loading_overlay.startAnimation(alphaAnimation)
loading_overlay?.startAnimation(alphaAnimation)
exoPlayer.setHandleAudioBecomingNoisy(true) // WHEN HEADPHONES ARE PLUGGED OUT https://github.com/google/ExoPlayer/issues/7288
player_view.player = exoPlayer
player_view?.player = exoPlayer
// Sets the speed
exoPlayer.playbackParameters = PlaybackParameters(playbackSpeed)
player_speed_text?.text =