Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f922c195 authored by Edgar Wang's avatar Edgar Wang Committed by Android (Google) Code Review
Browse files

Merge "[SettingsLib] SegmentedButtonPreference fix NullPointerException when...

Merge "[SettingsLib] SegmentedButtonPreference fix NullPointerException when view is inflating" into main
parents 4d1293db a862f8ed
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -30,30 +30,35 @@
        style="@style/Widget.Material3Expressive.MaterialButtonGroup.Connected"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="gone"
        app:singleSelection="true"
        app:selectionRequired="true"
        app:checkedButton="@id/button_1">
        <com.google.android.material.button.MaterialButton
            android:id="@+id/button_1"
            android:layout_weight="1"
            android:visibility="gone"
            app:iconPadding="0dp"
            app:iconGravity="textStart"
            style="@style/SettingsLibButtonStyle.Expressive.Tonal.Large"/>
        <com.google.android.material.button.MaterialButton
            android:id="@+id/button_2"
            android:layout_weight="1"
            android:visibility="gone"
            app:iconPadding="0dp"
            app:iconGravity="textStart"
            style="@style/SettingsLibButtonStyle.Expressive.Tonal.Large"/>
        <com.google.android.material.button.MaterialButton
            android:id="@+id/button_3"
            android:layout_weight="1"
            android:visibility="gone"
            app:iconPadding="0dp"
            app:iconGravity="textStart"
            style="@style/SettingsLibButtonStyle.Expressive.Tonal.Large"/>
        <com.google.android.material.button.MaterialButton
            android:id="@+id/button_4"
            android:layout_weight="1"
            android:visibility="gone"
            app:iconPadding="0dp"
            app:iconGravity="textStart"
            style="@style/SettingsLibButtonStyle.Expressive.Tonal.Large"/>
+5 −0
Original line number Diff line number Diff line
@@ -117,6 +117,11 @@ class SegmentedButtonPreference @JvmOverloads constructor(
    }

    private fun applyButtonSetupData() {
        // The button group is default gone to avoid NullPointerException
        // if all children's visibility are GONE.
        if(buttonSetupData.isNotEmpty()) {
            buttonGroup?.isGone = false
        }
        for ((index, config) in buttonSetupData) {
            applyButtonSetupData(index, config.first, config.second)
        }