]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/dialogs/EditBookmarkDatabaseViewDialog.kt
Save and restore the app state. https://redmine.stoutner.com/issues/461
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / dialogs / EditBookmarkDatabaseViewDialog.kt
index 4de3543173402cdd18c9d8fef528c161a9c3a610..a3c164521bdf22f98b72b80eab8b92f1a467c406 100644 (file)
@@ -205,7 +205,7 @@ class EditBookmarkDatabaseViewDialog: DialogFragment() {
         val matrixCursor = MatrixCursor(matrixCursorColumnNamesArray)
 
         // Add `Home Folder` as the first entry in the matrix folder.
-        matrixCursor.addRow(arrayOf<Any>(BookmarksDatabaseViewActivity.HOME_FOLDER_DATABASE_ID, getString(R.string.home_folder)))
+        matrixCursor.addRow(arrayOf(BookmarksDatabaseViewActivity.HOME_FOLDER_DATABASE_ID, getString(R.string.home_folder)))
 
         // Get a cursor with the list of all the folders.
         val foldersCursor = bookmarksDatabaseHelper.allFolders
@@ -321,15 +321,18 @@ class EditBookmarkDatabaseViewDialog: DialogFragment() {
             }
         })
 
-        // Update the edit button if the folder changes.
-        folderSpinner.onItemSelectedListener = object: OnItemSelectedListener {
-            override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
-                // Update the edit button.
-                updateEditButton(currentBookmarkName, currentUrl, currentFolderDatabaseId, currentDisplayOrder)
-            }
+        // Wait to set the on item selected listener until the spinner has been inflated.  Otherwise the dialog will crash on restart.
+        folderSpinner.post {
+            // Update the edit button if the folder changes.
+            folderSpinner.onItemSelectedListener = object : OnItemSelectedListener {
+                override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
+                    // Update the edit button.
+                    updateEditButton(currentBookmarkName, currentUrl, currentFolderDatabaseId, currentDisplayOrder)
+                }
 
-            override fun onNothingSelected(parent: AdapterView<*>?) {
-                // Do nothing.
+                override fun onNothingSelected(parent: AdapterView<*>?) {
+                    // Do nothing.
+                }
             }
         }