-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix category list not updating after name edit
The previous code had a strange bug. After you edit the category name with the dialog, it is *not* updated in the list. But looking at the database with the database inspector, you see that it was indeed updated. Also, if you click on edit again, the dialog does show the correctly updated name. But the actual list (recyclerview) does not. If you use the database inspector to manually change the name of a category, it is updated perfectly fine as you would expect livedata from room. It is even updated when the list is in the background of a dialog, but still visible. So we know that the room->livedata pipeline works. But apparently, it's not activated by the editing dialog. (I tried several things including the "nuclear" adapter.notifyDataSetChanged(), which worked, but should be used only if nothing else works.) The current solution changes what happens when the change dialog executes the positive button steps. When the user clicked "rename", before the change, we simply changed the name (which was a var for this reason) of the category object and try to update this object in the database. Now category is immutable (only vals) and we create a new category object with new name that is saved via viewModel. Now it works. To be honest, I don't know why. I can only speculate. But the important thing is that now it works as expected. #12
- Loading branch information
Showing
5 changed files
with
12 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters