[Android] Prevent crashes for the Video player info component
Nicolas Pomepuy
git at videolan.org
Fri Aug 13 09:01:32 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Aug 13 10:57:16 2021 +0200| [c258f1da40e69d842b2b5aa94d902022564b1cd4] | committer: Nicolas Pomepuy
Prevent crashes for the Video player info component
> https://code.videolan.org/videolan/vlc-android/commit/c258f1da40e69d842b2b5aa94d902022564b1cd4
---
.../src/main/java/org/videolan/liveplotgraph/LegendView.kt | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/application/live-plot-graph/src/main/java/org/videolan/liveplotgraph/LegendView.kt b/application/live-plot-graph/src/main/java/org/videolan/liveplotgraph/LegendView.kt
index c0bc482bd..c8c091054 100644
--- a/application/live-plot-graph/src/main/java/org/videolan/liveplotgraph/LegendView.kt
+++ b/application/live-plot-graph/src/main/java/org/videolan/liveplotgraph/LegendView.kt
@@ -71,10 +71,12 @@ class LegendView : ConstraintLayout, PlotViewDataChangeListener {
override fun onAttachedToWindow() {
super.onAttachedToWindow()
//workaround for editor
- if (!isInEditMode && context != null) {
- plotView = (context as Activity).findViewById(plotViewId)
- if (!::plotView.isInitialized) throw IllegalStateException("A valid plot view has to be provided")
- plotView.addListener(this)
+ if (!isInEditMode) {
+ context?.let {
+ plotView = (it as Activity).findViewById(plotViewId)
+ if (!::plotView.isInitialized) throw IllegalStateException("A valid plot view has to be provided")
+ plotView.addListener(this)
+ }
}
layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT
}
More information about the Android
mailing list