n-apps / ScoreCounter

Android app. Score Counter will help you easily keep score in any games, sports or other activities. Will do all the math for tracking initiative, HP, hit points, spell slots or even count win streaks in your bar game night!
GNU General Public License v3.0
70 stars 19 forks source link

Added ability to re-order counters #22

Closed PeterCeresnik closed 5 years ago

PeterCeresnik commented 5 years ago

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.

n-apps commented 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.

n-apps commented 5 years ago

Besides that exception, the drag and drop works great!

PeterCeresnik commented 5 years ago

That exception is thrown, because I updated database, if you uninstall app (or delete app cache) and than install it again, it will work.

PeterCeresnik commented 5 years ago

I added database migration from version 2 to 3, so the error won`t be thrown.

n-apps commented 4 years ago

https://github.com/n-apps/ScoreCounter/issues/51