Skip to content

Commit

Permalink
Fixed search EditText state sometimes lost when dialog is recreated
Browse files Browse the repository at this point in the history
  • Loading branch information
maltaisn committed May 1, 2020
1 parent 8892f11 commit db14241
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### v3.2.2
- Fixed crash when using raw color value for `icdIconColor` and `icdSelectedIconColor`.
- Fixed search EditText state sometimes lost when dialog is recreated.

### v3.2.1
- Updated Kotlin version to 1.3.72.
Expand Down
13 changes: 11 additions & 2 deletions lib/src/main/kotlin/com/maltaisn/icondialog/IconDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ class IconDialog : DialogFragment(), IconDialogContract.View {

// Restore layout manager state, which isn't saved by recycler view.
listLayout.onRestoreInstanceState(state.getParcelable("listLayoutState"))

// Restore search EditText state, which *should* be restored, but apparently isn't.
// The state of the view is actually saved in onSaveInstanceState, and it is still
// present here in the "state" bundle, but it doesn't get restored for some reason!
searchEdt.onRestoreInstanceState(state.getParcelable("searchEdtState"))
}

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

state.putParcelable("settings", settings)
state.putParcelable("listLayoutState", listLayout.onSaveInstanceState())

state.putParcelable("searchEdtState", searchEdt.onSaveInstanceState())

presenter?.saveState(state)
}

override fun onDestroy() {
super.onDestroy()
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)

searchHandler.removeCallbacks(searchCallback)

// Detach the presenter
Expand Down

0 comments on commit db14241

Please sign in to comment.