StwParser.kt now collects all its data before adding everything to the database all at once, fixing problems where LiveData would update before all transactions were finished; ViewPagers have been updated to use Adapters extending FragmentStateAdapter instead of RecyclerView.Adapter

This commit is contained in:
denizk0461
2023-04-27 21:58:10 +02:00
parent ccd77a5daf
commit ce7b854e8c
15 changed files with 373 additions and 164 deletions
@@ -49,7 +49,7 @@ interface AppDAO {
*
* @param events objects to be saved to the database
*/
@Insert fun insert(events: List<StudIPEvent>)
@Insert fun insertEvents(events: List<StudIPEvent>)
/**
* Deletes all Stud.IP events from the database.
@@ -124,17 +124,31 @@ interface AppDAO {
/**
* Inserts a date into the database.
*
* @param date object to be saved to the database
* @param date object to be saved to the database
*/
@Insert fun insert(date: OfferDate)
/**
* Inserts a list of dates into the database.
*
* @param dates objects to be saved to the database
*/
@Insert fun insertDates(dates: List<OfferDate>)
/**
* Inserts a canteen into the database.
*
* @param canteen object to be saved to the database
* @param canteen object to be saved to the database
*/
@Insert fun insert(canteen: OfferCanteen)
/**
* Inserts a list of canteens into the database.
*
* @param canteens objects to be saved to the database
*/
@Insert fun insertCanteens(canteens: List<OfferCanteen>)
/**
* Inserts a canteen offer category into the database.
*
@@ -142,6 +156,13 @@ interface AppDAO {
*/
@Insert fun insert(category: OfferCategory)
/**
* Inserts a list of categories into the database.
*
* @param categories objects to be saved to the database
*/
@Insert fun insertCategories(categories: List<OfferCategory>)
/**
* Inserts a canteen offer item into the database.
*
@@ -149,6 +170,13 @@ interface AppDAO {
*/
@Insert fun insert(item: OfferItem)
/**
* Inserts a list of items into the database.
*
* @param items objects to be saved to the database
*/
@Insert fun insertItems(items: List<OfferItem>)
/**
* Retrieves the opening hours of the canteen as a string.
*
@@ -37,7 +37,7 @@ class AppRepository(app: Application) {
*
* @param events objects to be saved to the database
*/
fun insertEvents(events: List<StudIPEvent>) { dao.insert(events) }
fun insertEvents(events: List<StudIPEvent>) { dao.insertEvents(events) }
/**
* Deletes all Stud.IP events from the database.
@@ -173,13 +173,27 @@ class AppRepository(app: Application) {
*/
fun insert(date: OfferDate) { dao.insert(date) }
/**
* Inserts a list of dates into the database.
*
* @param dates objects to be saved to the database
*/
fun insertDates(dates: List<OfferDate>) { dao.insertDates(dates) }
/**
* Inserts a canteen into the database.
*
* @param canteen object to be saved to the database
* @param canteen object to be saved to the database
*/
fun insert(canteen: OfferCanteen) { dao.insert(canteen) }
/**
* Inserts a list of canteens into the database.
*
* @param canteens objects to be saved to the database
*/
fun insertCanteens(canteens: List<OfferCanteen>) { dao.insertCanteens(canteens) }
/**
* Inserts a canteen offer category into the database.
*
@@ -187,6 +201,13 @@ class AppRepository(app: Application) {
*/
fun insert(category: OfferCategory) { dao.insert(category) }
/**
* Inserts a list of categories into the database.
*
* @param categories objects to be saved to the database
*/
fun insertCategories(categories: List<OfferCategory>) { dao.insertCategories(categories) }
/**
* Inserts a canteen offer item into the database.
*
@@ -194,6 +215,13 @@ class AppRepository(app: Application) {
*/
fun insert(item: OfferItem) { dao.insert(item) }
/**
* Inserts a list of items into the database.
*
* @param items objects to be saved to the database
*/
fun insertItems(items: List<OfferItem>) { dao.insertItems(items) }
// --- settings preferences --- //
/**