From ee09f604b854a913d7c531ca0d77c86cb92975d4 Mon Sep 17 00:00:00 2001 From: LagradOst Date: Mon, 11 Oct 2021 00:25:49 +0200 Subject: [PATCH] minor crash fixes --- .../lagradost/cloudstream3/ui/home/HomeFragment.kt | 10 +++++++++- .../cloudstream3/ui/player/PlayerFragment.kt | 14 +++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt index dc22a2a0..e1a76d57 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt @@ -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() diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt index 20c26c69..b7e8ccf7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt @@ -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 =