Closed PeterCeresnik closed 5 years ago
After installing over previous version java.lang.IllegalStateException: A migration from 2 to 3 was required but not found. Please provide the necessary Migration path via RoomDatabase.Builder.addMigration(Migration ...) or allow for destructive migrations via one of the RoomDatabase.Builder.fallbackToDestructiveMigration* methods.
Besides that exception, the drag and drop works great!
That exception is thrown, because I updated database, if you uninstall app (or delete app cache) and than install it again, it will work.
I added database migration from version 2 to 3, so the error won`t be thrown.
I added reordering mechanism for counter’s recycler view. When you long press counter’s header, you can drag counter to new position within recycler view. You can also change counter position from counter’s details screen by specifying new position through a dialog window. I changed database handling (added field position), repository and view models for both CountersFragment and EditCounterActivity. Items dragging is handled by extending ItemTouchHelper.Callback class. During dragging event items are moved within CountersAdapter and only after the event, changes are populated to the database. I spend many hours trying to fix issue during dragging. When item was moved to the top of recycler view with two grid columns, it was placed above the bound of recycler view and that generated many other problems. When I finally tried changing staggeredgridlayoutmanager to basic gridlayoutmanager mentioned problems have disappeared.