Removed redundant AsyncTasks from repository calls as they are only accessed asynchronously in DataFetcher.kt

This commit is contained in:
Deniz Düzgören
2019-10-13 21:22:46 +02:00
parent bbecb640ea
commit 28656db878
2 changed files with 4 additions and 36 deletions
@@ -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()
}
}