[Android] TV background: prevent NPE
Geoffrey Métais
git at videolan.org
Tue Jan 8 11:26:56 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jan 7 17:49:11 2019 +0100| [c6a92dfedf75bc8f7e6d12835f7c950ebdfe0259] | committer: Geoffrey Métais
TV background: prevent NPE
> https://code.videolan.org/videolan/vlc-android/commit/c6a92dfedf75bc8f7e6d12835f7c950ebdfe0259
---
vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt b/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt
index 56c5ffb98..f48cb45e8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.kt
@@ -28,15 +28,14 @@ import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.net.Uri
import android.os.Build
+import android.text.TextUtils
+import android.view.View
import androidx.annotation.RequiresApi
+import androidx.core.content.ContextCompat
import androidx.leanback.app.BackgroundManager
import androidx.leanback.widget.DiffCallback
import androidx.leanback.widget.ListRow
import androidx.leanback.widget.Row
-import androidx.fragment.app.FragmentActivity
-import androidx.core.content.ContextCompat
-import android.text.TextUtils
-import android.view.View
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -46,7 +45,6 @@ import org.videolan.medialibrary.media.MediaWrapper
import org.videolan.vlc.R
import org.videolan.vlc.VLCApplication
import org.videolan.vlc.gui.DialogActivity
-import org.videolan.vlc.gui.dialogs.NetworkServerDialog
import org.videolan.vlc.gui.helpers.AudioUtil
import org.videolan.vlc.gui.helpers.BitmapUtil
import org.videolan.vlc.gui.helpers.UiTools
@@ -199,14 +197,18 @@ object TvUtil {
cover = BitmapUtil.centerCrop(cover, cover!!.width, cover.width * 10 / 16)
UiTools.blurBitmap(cover, 10f)
}
- bm.color = 0
- bm.drawable = BitmapDrawable(VLCApplication.getAppResources(), blurred)
+ @Suppress("SENSELESS_COMPARISON")
+ if (bm !== null) {
+ bm.color = 0
+ bm.drawable = BitmapDrawable(VLCApplication.getAppResources(), blurred)
+ }
}
}
clearBackground(bm)
}
- private fun clearBackground(bm: BackgroundManager) {
+ private fun clearBackground(bm: BackgroundManager?) {
+ if (bm === null) return
bm.color = ContextCompat.getColor(VLCApplication.getAppContext(), R.color.tv_bg)
bm.drawable = null
}
More information about the Android
mailing list