@@ -94,9 +94,8 @@ internal class FlexItemEditFragment : DialogFragment() {
9494 dialog.setTitle((viewIndex + 1 ).toString())
9595
9696 val activity = activity
97- val orderTextInput = view
98- .findViewById(R .id.input_layout_order) as TextInputLayout
99- val orderEdit = view.findViewById(R .id.edit_text_order) as EditText
97+ val orderTextInput: TextInputLayout = view.findViewById(R .id.input_layout_order)
98+ val orderEdit: EditText = view.findViewById(R .id.edit_text_order)
10099 orderEdit.setText(flexItem.order.toString())
101100 orderEdit.addTextChangedListener(
102101 FlexEditTextWatcher (activity, orderTextInput, IntegerInputValidator (),
@@ -106,26 +105,23 @@ internal class FlexItemEditFragment : DialogFragment() {
106105 orderEdit.isEnabled = false
107106 }
108107
109- val flexGrowInput = view
110- .findViewById(R .id.input_layout_flex_grow) as TextInputLayout
111- val flexGrowEdit = view.findViewById(R .id.edit_text_flex_grow) as EditText
108+ val flexGrowInput: TextInputLayout = view .findViewById(R .id.input_layout_flex_grow)
109+ val flexGrowEdit: EditText = view.findViewById(R .id.edit_text_flex_grow)
112110 flexGrowEdit.setText(flexItem.flexGrow.toString())
113111 flexGrowEdit.addTextChangedListener(
114112 FlexEditTextWatcher (activity, flexGrowInput, NonNegativeDecimalInputValidator (),
115113 R .string.must_be_non_negative_float))
116114
117- val flexShrinkInput = view
118- .findViewById(R .id.input_layout_flex_shrink) as TextInputLayout
119- val flexShrinkEdit = view.findViewById(
120- R .id.edit_text_flex_shrink) as EditText
115+ val flexShrinkInput: TextInputLayout = view.findViewById(R .id.input_layout_flex_shrink)
116+ val flexShrinkEdit: EditText = view.findViewById(R .id.edit_text_flex_shrink)
121117 flexShrinkEdit.setText(flexItem.flexShrink.toString())
122118 flexShrinkEdit.addTextChangedListener(
123119 FlexEditTextWatcher (activity, flexShrinkInput, NonNegativeDecimalInputValidator (),
124120 R .string.must_be_non_negative_float))
125121
126- val flexBasisPercentInput = view.findViewById( R .id.input_layout_flex_basis_percent) as TextInputLayout
127- val flexBasisPercentEdit = view.findViewById(
128- R .id.edit_text_flex_basis_percent) as EditText
122+ val flexBasisPercentInput: TextInputLayout =
123+ view.findViewById(R .id.input_layout_flex_basis_percent)
124+ val flexBasisPercentEdit : EditText = view.findViewById( R .id.edit_text_flex_basis_percent)
129125 if (flexItem.flexBasisPercent != FlexboxLayout .LayoutParams .FLEX_BASIS_PERCENT_DEFAULT ) {
130126 flexBasisPercentEdit
131127 .setText(Math .round(flexItem.flexBasisPercent * 100 ).toString())
@@ -136,52 +132,43 @@ internal class FlexItemEditFragment : DialogFragment() {
136132 FlexEditTextWatcher (activity, flexBasisPercentInput, FlexBasisPercentInputValidator (),
137133 R .string.must_be_minus_one_or_non_negative_integer))
138134
139- val widthInput = view
140- .findViewById(R .id.input_layout_width) as TextInputLayout
141- val widthEdit = view.findViewById(R .id.edit_text_width) as EditText
135+ val widthInput: TextInputLayout = view.findViewById(R .id.input_layout_width)
136+ val widthEdit: EditText = view.findViewById(R .id.edit_text_width)
142137 widthEdit.setText(activity.pixelToDp(flexItem.width).toString())
143138 widthEdit.addTextChangedListener(
144139 FlexEditTextWatcher (activity, widthInput, DimensionInputValidator (),
145140 R .string.must_be_minus_one_or_minus_two_or_non_negative_integer))
146141
147- val heightInput = view
148- .findViewById(R .id.input_layout_height) as TextInputLayout
149- val heightEdit = view.findViewById(
150- R .id.edit_text_height) as EditText
142+ val heightInput: TextInputLayout = view.findViewById(R .id.input_layout_height)
143+ val heightEdit: EditText = view.findViewById(R .id.edit_text_height)
151144 heightEdit.setText(activity.pixelToDp(flexItem.height).toString())
152145 heightEdit.addTextChangedListener(
153146 FlexEditTextWatcher (activity, heightInput, DimensionInputValidator (),
154147 R .string.must_be_minus_one_or_minus_two_or_non_negative_integer))
155148
156- val minWidthInput = view
157- .findViewById(R .id.input_layout_min_width) as TextInputLayout
158- val minWidthEdit = view.findViewById(R .id.edit_text_min_width) as EditText
149+ val minWidthInput: TextInputLayout = view.findViewById(R .id.input_layout_min_width)
150+ val minWidthEdit: EditText = view.findViewById(R .id.edit_text_min_width)
159151 minWidthEdit.setText(activity.pixelToDp(flexItem.minWidth).toString())
160152 minWidthEdit.addTextChangedListener(
161153 FlexEditTextWatcher (activity, minWidthInput, FixedDimensionInputValidator (),
162154 R .string.must_be_non_negative_integer))
163155
164- val minHeightInput = view
165- .findViewById(R .id.input_layout_min_height) as TextInputLayout
166- val minHeightEdit = view.findViewById(
167- R .id.edit_text_min_height) as EditText
156+ val minHeightInput: TextInputLayout = view.findViewById(R .id.input_layout_min_height)
157+ val minHeightEdit: EditText = view.findViewById(R .id.edit_text_min_height)
168158 minHeightEdit.setText(activity.pixelToDp(flexItem.minHeight).toString())
169159 minHeightEdit.addTextChangedListener(
170160 FlexEditTextWatcher (activity, minHeightInput, FixedDimensionInputValidator (),
171161 R .string.must_be_non_negative_integer))
172162
173- val maxWidthInput = view
174- .findViewById(R .id.input_layout_max_width) as TextInputLayout
175- val maxWidthEdit = view.findViewById(R .id.edit_text_max_width) as EditText
163+ val maxWidthInput: TextInputLayout = view.findViewById(R .id.input_layout_max_width)
164+ val maxWidthEdit: EditText = view.findViewById(R .id.edit_text_max_width)
176165 maxWidthEdit.setText(activity.pixelToDp(flexItem.maxWidth).toString())
177166 maxWidthEdit.addTextChangedListener(
178167 FlexEditTextWatcher (activity, maxWidthInput, FixedDimensionInputValidator (),
179168 R .string.must_be_non_negative_integer))
180169
181- val maxHeightInput = view
182- .findViewById(R .id.input_layout_max_height) as TextInputLayout
183- val maxHeightEdit = view.findViewById(
184- R .id.edit_text_max_height) as EditText
170+ val maxHeightInput: TextInputLayout = view.findViewById(R .id.input_layout_max_height)
171+ val maxHeightEdit: EditText = view.findViewById(R .id.edit_text_max_height)
185172 maxHeightEdit.setText(activity.pixelToDp(flexItem.maxHeight).toString())
186173 maxHeightEdit.addTextChangedListener(
187174 FlexEditTextWatcher (activity, maxHeightInput, FixedDimensionInputValidator (),
@@ -190,8 +177,7 @@ internal class FlexItemEditFragment : DialogFragment() {
190177 setNextFocusesOnEnterDown(orderEdit, flexGrowEdit, flexShrinkEdit, flexBasisPercentEdit,
191178 widthEdit, heightEdit, minWidthEdit, minHeightEdit, maxWidthEdit, maxHeightEdit)
192179
193- val alignSelfSpinner = view.findViewById(
194- R .id.spinner_align_self) as Spinner
180+ val alignSelfSpinner: Spinner = view.findViewById(R .id.spinner_align_self)
195181 val arrayAdapter = ArrayAdapter .createFromResource(activity,
196182 R .array.array_align_self, R .layout.spinner_item)
197183 alignSelfSpinner.adapter = arrayAdapter
@@ -213,18 +199,18 @@ internal class FlexItemEditFragment : DialogFragment() {
213199 }
214200 }
215201
216- val wrapBeforeCheckBox = view.findViewById(R .id.checkbox_wrap_before) as CheckBox
202+ val wrapBeforeCheckBox: CheckBox = view.findViewById(R .id.checkbox_wrap_before)
217203 wrapBeforeCheckBox.isChecked = flexItem.isWrapBefore
218204 wrapBeforeCheckBox.setOnCheckedChangeListener { _, isChecked -> flexItemInEdit.isWrapBefore = isChecked }
219205 val alignSelfPosition = arrayAdapter
220206 .getPosition(alignSelfAsString(flexItem.alignSelf))
221207 alignSelfSpinner.setSelection(alignSelfPosition)
222208
223- view.findViewById(R .id.button_cancel).setOnClickListener {
209+ view.findViewById< Button > (R .id.button_cancel).setOnClickListener {
224210 copyFlexItemValues(flexItem, flexItemInEdit)
225211 dismiss()
226212 }
227- val okButton = view.findViewById(R .id.button_ok) as Button
213+ val okButton: Button = view.findViewById(R .id.button_ok)
228214 okButton.setOnClickListener(View .OnClickListener {
229215 if (orderTextInput.isErrorEnabled || flexGrowInput.isErrorEnabled ||
230216 flexBasisPercentInput.isErrorEnabled || widthInput.isErrorEnabled ||
0 commit comments