改造objectbox
This commit is contained in:
@@ -47,9 +47,11 @@ object FoodModule {
|
||||
suspend fun init(context: Context) {
|
||||
withContext(Dispatchers.IO) {
|
||||
module_mobile = Module.load(copyAssetToCache(context, "best_embedding_model_mobile.pt"))
|
||||
val box = ObjectBox.getBox<Food>()
|
||||
if (box?.all?.isEmpty() == true) {
|
||||
initDefFoodData(context)
|
||||
ObjectBox.safeDbOp {
|
||||
val box = ObjectBox.getBox<Food>()
|
||||
if (box?.all?.isEmpty() == true) {
|
||||
initDefFoodData(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user