Skip to content

Commit db14241

Browse files
committed
Fixed search EditText state sometimes lost when dialog is recreated
1 parent 8892f11 commit db14241

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### v3.2.2
22
- Fixed crash when using raw color value for `icdIconColor` and `icdSelectedIconColor`.
3+
- Fixed search EditText state sometimes lost when dialog is recreated.
34

45
### v3.2.1
56
- Updated Kotlin version to 1.3.72.

lib/src/main/kotlin/com/maltaisn/icondialog/IconDialog.kt

+11-2
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ class IconDialog : DialogFragment(), IconDialogContract.View {
211211

212212
// Restore layout manager state, which isn't saved by recycler view.
213213
listLayout.onRestoreInstanceState(state.getParcelable("listLayoutState"))
214+
215+
// Restore search EditText state, which *should* be restored, but apparently isn't.
216+
// The state of the view is actually saved in onSaveInstanceState, and it is still
217+
// present here in the "state" bundle, but it doesn't get restored for some reason!
218+
searchEdt.onRestoreInstanceState(state.getParcelable("searchEdtState"))
214219
}
215220

216221
return dialog
@@ -234,11 +239,15 @@ class IconDialog : DialogFragment(), IconDialogContract.View {
234239

235240
state.putParcelable("settings", settings)
236241
state.putParcelable("listLayoutState", listLayout.onSaveInstanceState())
242+
243+
state.putParcelable("searchEdtState", searchEdt.onSaveInstanceState())
244+
237245
presenter?.saveState(state)
238246
}
239247

240-
override fun onDestroy() {
241-
super.onDestroy()
248+
override fun onDismiss(dialog: DialogInterface) {
249+
super.onDismiss(dialog)
250+
242251
searchHandler.removeCallbacks(searchCallback)
243252

244253
// Detach the presenter

0 commit comments

Comments
 (0)