Skip to content

Commit b5ce3f1

Browse files
authored
Fix crash on rotation. (#392)
By chanigng the View type as nullable in onItemSelected
1 parent 5835b17 commit b5ce3f1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

demo-playground/src/main/java/com/google/android/flexbox/FlexItemEditFragment.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ internal class FlexItemEditFragment : DialogFragment() {
180180
R.array.array_align_self, R.layout.spinner_item)
181181
alignSelfSpinner.adapter = arrayAdapter
182182
alignSelfSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
183-
override fun onItemSelected(parent: AdapterView<*>, ignored: View, position: Int, id: Long) {
183+
override fun onItemSelected(parent: AdapterView<*>, ignored: View?, position: Int,
184+
id: Long) {
184185
flexItemInEdit.alignSelf = when (parent.getItemAtPosition(position).toString()) {
185186
alignSelfAuto -> AlignSelf.AUTO
186187
alignSelfFlexStart -> AlignItems.FLEX_START
@@ -199,7 +200,8 @@ internal class FlexItemEditFragment : DialogFragment() {
199200

200201
val wrapBeforeCheckBox: CheckBox = view.findViewById(R.id.checkbox_wrap_before)
201202
wrapBeforeCheckBox.isChecked = flexItem.isWrapBefore
202-
wrapBeforeCheckBox.setOnCheckedChangeListener { _, isChecked -> flexItemInEdit.isWrapBefore = isChecked }
203+
wrapBeforeCheckBox.setOnCheckedChangeListener { _, isChecked ->
204+
flexItemInEdit.isWrapBefore = isChecked }
203205
val alignSelfPosition = arrayAdapter
204206
.getPosition(alignSelfAsString(flexItem.alignSelf))
205207
alignSelfSpinner.setSelection(alignSelfPosition)

0 commit comments

Comments
 (0)