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) {
|
fun insert(food: Food) {
|
||||||
InsertAsync(substDao).execute(food)
|
substDao?.insertFood(food)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteAll() {
|
fun deleteAll() {
|
||||||
DeleteAllAsync(substDao).execute()
|
substDao?.deleteAllFoods()
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,26 +21,10 @@ internal class SubstRepository(application: Application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun insert(substitution: Substitution) {
|
fun insert(substitution: Substitution) {
|
||||||
InsertSubstAsync(substDao).execute(substitution)
|
substDao?.insertSubst(substitution)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteAllSubst() {
|
fun deleteAllSubst() {
|
||||||
DeleteAllSubstAsync(substDao).execute()
|
substDao?.deleteAllSubst()
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user