Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: use viewmodel for EditIngredientsFragment.kt
feat: add dokka to build.gradle.kts
- Loading branch information
Showing
9 changed files
with
181 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
268 changes: 141 additions & 127 deletions
268
...ct/edit/ProductEditIngredientsFragment.kt → ...it/ingredients/EditIngredientsFragment.kt
Large diffs are not rendered by default.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
...cts/github/scrachx/openfood/features/product/edit/ingredients/EditIngredientsViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package openfoodfacts.github.scrachx.openfood.features.product.edit.ingredients | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.liveData | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import openfoodfacts.github.scrachx.openfood.models.DaoSession | ||
import openfoodfacts.github.scrachx.openfood.models.entities.allergen.AllergenNameDao | ||
import openfoodfacts.github.scrachx.openfood.utils.LocaleManager | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class EditIngredientsViewModel @Inject constructor( | ||
private val daoSession: DaoSession, | ||
private val localeManager: LocaleManager | ||
) : ViewModel() { | ||
|
||
val allergens = liveData { | ||
daoSession.allergenNameDao.queryBuilder() | ||
.where(AllergenNameDao.Properties.LanguageCode.eq(localeManager.getLanguage())) | ||
.orderDesc(AllergenNameDao.Properties.Name) | ||
.list() | ||
.map { it.name } | ||
.let { emit(it) } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters