Archived
Removed redundant AsyncTasks from repository calls as they are only accessed asynchronously in DataFetcher.kt
This commit is contained in:
@@ -18,26 +18,10 @@ internal class FoodRepository(application: Application) {
|
||||
}
|
||||
|
||||
fun insert(food: Food) {
|
||||
InsertAsync(substDao).execute(food)
|
||||
substDao?.insertFood(food)
|
||||
}
|
||||
|
||||
fun deleteAll() {
|
||||
DeleteAllAsync(substDao).execute()
|
||||
}
|
||||
|
||||
class InsertAsync(substDao: SubstDao?) : AsyncTask<Food, Void, Void>() {
|
||||
private val mSubstDao = substDao
|
||||
override fun doInBackground(vararg foods: Food): Void? {
|
||||
mSubstDao?.insertFood(foods[0])
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class DeleteAllAsync(substDao: SubstDao?) : AsyncTask<Void, Void, Void>() {
|
||||
private val mSubstDao = substDao
|
||||
override fun doInBackground(vararg voids: Void): Void? {
|
||||
mSubstDao?.deleteAllFoods()
|
||||
return null
|
||||
}
|
||||
substDao?.deleteAllFoods()
|
||||
}
|
||||
}
|
||||
@@ -21,26 +21,10 @@ internal class SubstRepository(application: Application) {
|
||||
}
|
||||
|
||||
fun insert(substitution: Substitution) {
|
||||
InsertSubstAsync(substDao).execute(substitution)
|
||||
substDao?.insertSubst(substitution)
|
||||
}
|
||||
|
||||
fun deleteAllSubst() {
|
||||
DeleteAllSubstAsync(substDao).execute()
|
||||
}
|
||||
|
||||
class InsertSubstAsync(substDao: SubstDao?) : AsyncTask<Substitution, Void, Void>() {
|
||||
private val mSubstDao = substDao
|
||||
override fun doInBackground(vararg substitutions: Substitution): Void? {
|
||||
mSubstDao?.insertSubst(substitutions[0])
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class DeleteAllSubstAsync(substDao: SubstDao?) : AsyncTask<Void, Void, Void>() {
|
||||
private val mSubstDao = substDao
|
||||
override fun doInBackground(vararg voids: Void): Void? {
|
||||
mSubstDao?.deleteAllSubst()
|
||||
return null
|
||||
}
|
||||
substDao?.deleteAllSubst()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user