mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
Refactor: Migrate to Room Database for Bookmark Locations
This commit migrates the bookmark locations functionality from a custom content provider to Room database.
Key changes:
* **Removal of `BookmarkLocationsContentProvider`:** This class, which previously handled data storage, has been removed.
* **Introduction of `BookmarksLocations`:** This data class now represents a bookmarked location, serving as the Room entity.
* **Creation of `BookmarkLocationsDao`:** This Room DAO handles database interactions for bookmark locations, including:
* Adding, deleting, and querying bookmarked locations.
* Checking if a location is already bookmarked.
* Updating the bookmark status of a location.
* Retrieving all bookmarked locations as `Place` objects.
* **`BookmarkLocationsViewModel`:** Added to manage the data layer for bookmark locations
* **`NearbyUtil`:** Created a Util class for Nearby to manage the bookmark locations.
* **Updates in `PlaceAdapter` and `PlaceAdapterDelegate`:** These classes have been modified to work with the new Room-based data layer.
* **Updates in `AppDatabase`:** The database now includes `BookmarksLocations` as an entity and exposes the `bookmarkLocationsDao`.
* **Updates in `FragmentBuilderModule` and `CommonsApplicationModule`**: for DI
* **Removal of `DBOpenHelper` upgrade for locations**: as it is no longer needed
* **Updates in `NearbyParentFragmentPresenter`**: refactored the logic to use the dao functions
* **Updates in `NearbyParentFragment`**: refactored the logic to use the util and dao functions
* **Update in `BookmarkLocationsController`**: removed as its no longer needed
* **Add `toPlace` and `toBookmarksLocations`**: extension functions to map between data class and entities
* **Update in `CommonsApplication`**: to remove old db table.
This commit is contained in:
parent
313f61538f
commit
54d0f65294
18 changed files with 210 additions and 429 deletions
|
|
@ -5,6 +5,8 @@ import androidx.room.RoomDatabase
|
|||
import androidx.room.TypeConverters
|
||||
import fr.free.nrw.commons.bookmarks.category.BookmarkCategoriesDao
|
||||
import fr.free.nrw.commons.bookmarks.category.BookmarksCategoryModal
|
||||
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao
|
||||
import fr.free.nrw.commons.bookmarks.locations.BookmarksLocations
|
||||
import fr.free.nrw.commons.contributions.Contribution
|
||||
import fr.free.nrw.commons.contributions.ContributionDao
|
||||
import fr.free.nrw.commons.customselector.database.NotForUploadStatus
|
||||
|
|
@ -23,7 +25,7 @@ import fr.free.nrw.commons.upload.depicts.DepictsDao
|
|||
*
|
||||
*/
|
||||
@Database(
|
||||
entities = [Contribution::class, Depicts::class, UploadedStatus::class, NotForUploadStatus::class, ReviewEntity::class, Place::class, BookmarksCategoryModal::class],
|
||||
entities = [Contribution::class, Depicts::class, UploadedStatus::class, NotForUploadStatus::class, ReviewEntity::class, Place::class, BookmarksCategoryModal::class, BookmarksLocations::class],
|
||||
version = 19,
|
||||
exportSchema = false,
|
||||
)
|
||||
|
|
@ -42,4 +44,6 @@ abstract class AppDatabase : RoomDatabase() {
|
|||
abstract fun ReviewDao(): ReviewDao
|
||||
|
||||
abstract fun bookmarkCategoriesDao(): BookmarkCategoriesDao
|
||||
|
||||
abstract fun bookmarkLocationsDao(): BookmarkLocationsDao
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue