Skip to content

Commit 0675588

Browse files
fix: added null check on Android ViewGroup
1 parent ee22df7 commit 0675588

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

android/src/main/java/com/lodev09/truesheet/TrueSheetDialog.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
7070
var backgroundColor: Int = Color.WHITE
7171

7272
// 1st child is the content view
73-
val contentView: ViewGroup
74-
get() = containerView.getChildAt(0) as ViewGroup
73+
val contentView: ViewGroup?
74+
get() = containerView.getChildAt(0) as? ViewGroup
7575

7676
// 2nd child is the footer view
77-
val footerView: ViewGroup
78-
get() = containerView.getChildAt(1) as ViewGroup
77+
val footerView: ViewGroup?
78+
get() = containerView.getChildAt(1) as? ViewGroup
7979

8080
var sizes: Array<Any> = arrayOf("medium", "large")
8181

@@ -196,7 +196,7 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
196196
}
197197

198198
fun positionFooter() {
199-
footerView.apply {
199+
footerView?.apply {
200200
y = (maxScreenHeight - sheetContainerView.top - footerHeight).toFloat()
201201
}
202202
}

android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ class TrueSheetView(context: Context) :
178178

179179
// Initialize content
180180
UiThreadUtil.runOnUiThread {
181-
setContentHeight(sheetDialog.contentView.height)
182-
setFooterHeight(sheetDialog.footerView.height)
181+
sheetDialog.contentView?.height?.let { setContentHeight(it) }
182+
sheetDialog.footerView?.height?.let { setFooterHeight(it) }
183183

184184
if (initialIndex >= 0) {
185185
currentSizeIndex = initialIndex

0 commit comments

Comments
 (0)