Selaa lähdekoodia

提交人:江天明
提交内容:优化

江天明 9 kuukautta sitten
vanhempi
commit
b19bf22c68

+ 6 - 0
BusinessMain/src/main/java/com/develop/main/init/ui/FoodListActivity.kt

@@ -2,6 +2,7 @@ package com.develop.main.init.ui
 
 import android.graphics.Rect
 import android.os.Bundle
+import android.util.Log
 import android.view.LayoutInflater
 import android.view.View
 import androidx.recyclerview.widget.RecyclerView
@@ -181,11 +182,16 @@ class FoodListActivity : BaseActivity<ActivityFoodListBinding>() {
             val recipesIdList = mutableListOf<String>()
             val favoriteRecipesIds = mutableListOf<String>()
             userDao.queryUserOnLineRecipesIds().forEach {
+                Log.d("ddddddd",it.onLineRecipesId)
                 recipesIdList.add(it.onLineRecipesId)
             }
+            userDao.queryFavoriteRecipes(CURRENT_USER_ID).forEach {
+                favoriteRecipesIds.add(it.favoriteRecipesId)
+            }
             val recipesList = mutableListOf<DevRecipe>()
             recipesIdList.forEach {
                 recipesDao.queryRecipe(it)?.apply {
+                    Log.d("ddddddd","${this.number}==${this.name}")
                     recipesList.add(this)
                 }
             }

+ 6 - 1
BusinessStep/src/main/java/com/develop/step/details/CookDetailViewModel.kt

@@ -1,6 +1,7 @@
 package com.develop.step.details
 
 import android.app.Application
+import android.util.Log
 import androidx.lifecycle.AndroidViewModel
 import androidx.lifecycle.LiveData
 import androidx.lifecycle.MutableLiveData
@@ -14,6 +15,7 @@ import com.develop.food.base.http.observeStatus
 import com.develop.food.base.repo.CURRENT_USER_ID
 import com.develop.food.base.repo.FoodDataProvider
 import com.develop.food.base.repo.entity.DevAccessory
+import com.develop.food.base.repo.entity.DevRecipe
 import com.develop.food.base.repo.entity.DevRecipeCategory
 import com.develop.food.base.repo.entity.DevRecipePortionSize
 import com.develop.food.base.repo.entity.UserOnLineRecipes
@@ -196,7 +198,8 @@ class CookDetailViewModel(application: Application) : AndroidViewModel(applicati
             }
             val jsonContent = FileKit.readFileToStringB(jsonFile)
             val contentData = Gson().fromJson(jsonContent, RecipeDataConfig::class.java)
-            contentData.resetAllCodes()
+            Log.d("jsonContent",jsonContent)
+            //contentData.resetAllCodes()
             FoodDataProvider.getDatabase().runInTransaction {
                 FoodDataProvider.getDatabase().recipeDao().apply {
                     val categorys = queryAllCategory()
@@ -222,6 +225,7 @@ class CookDetailViewModel(application: Application) : AndroidViewModel(applicati
                     insertDevRecipeRelTags(contentData.devRecipeRelTags)
                     insertDevRecipeTags(contentData.devRecipeTags)
                     insertDevRecipes(contentData.devRecipes)
+                    Log.d("jsonContent",Gson().toJson(contentData.devRecipes[0]))
                 }
                 ThreadUtils.runOnMainThread {
                     downloadResource.value = Resource(100, Resource.Status.SUCCESS)
@@ -232,6 +236,7 @@ class CookDetailViewModel(application: Application) : AndroidViewModel(applicati
                     FoodDataProvider.getUserDatabase().userInfoDao().insertOnlineRecipe(
                         UserOnLineRecipes(CURRENT_USER_ID, it.number ?: "")
                     )
+                    Log.d("jsonContent","更新菜谱:${it.number}==${it.name}")
                 }
             }
         } catch (e: Exception) {

+ 8 - 9
BusinessStep/src/main/res/layout/activity_food_step2.xml

@@ -33,15 +33,15 @@
             android:layout_width="0dp"
             android:layout_height="match_parent"
             android:layout_marginStart="@dimen/convert_51px"
-            android:layout_marginEnd="@dimen/convert_70px"
-            android:ellipsize="end"
-            android:gravity="center"
+            android:layout_marginEnd="40dp"
+            android:ellipsize="marquee"
             android:focusable="true"
+            android:gravity="center"
             android:singleLine="true"
             android:text="Step1:Peel 3 onions(180g)and2..."
             android:textColor="#ffffff"
             android:textSize="@dimen/convert_45px"
-            app:layout_constraintEnd_toStartOf="@+id/view_alarm"
+            app:layout_constraintEnd_toStartOf="@+id/view_step_mark"
             app:layout_constraintStart_toEndOf="@+id/view_back" />
 
         <View
@@ -54,17 +54,16 @@
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintTop_toTopOf="parent" />
-        
+
         <View
             android:id="@+id/view_step_mark"
+            android:layout_width="@dimen/convert_50px"
+            android:layout_height="@dimen/convert_66px"
             android:layout_marginEnd="@dimen/convert_84px"
             android:background="@drawable/view_step"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintTop_toTopOf="parent"
-            android:layout_width="@dimen/convert_50px"
-            android:layout_height="@dimen/convert_66px"
-            />
+            app:layout_constraintTop_toTopOf="parent" />
 
     </androidx.constraintlayout.widget.ConstraintLayout>
 

+ 7 - 2
libBase/src/main/java/com/develop/food/base/repo/db/UserDatabase.kt

@@ -1,12 +1,17 @@
 package com.develop.food.base.repo.db
 
-import android.annotation.SuppressLint
 import androidx.room.AutoMigration
 import androidx.room.Database
 import androidx.room.RoomDatabase
 import com.develop.food.base.repo.db.dao.DevConfigDao
 import com.develop.food.base.repo.db.dao.UserInfoDao
-import com.develop.food.base.repo.entity.*
+import com.develop.food.base.repo.entity.DevVersion
+import com.develop.food.base.repo.entity.UserFavoriteRecipes
+import com.develop.food.base.repo.entity.UserHistoryRecipes
+import com.develop.food.base.repo.entity.UserInfo
+import com.develop.food.base.repo.entity.UserOnLineRecipes
+import com.develop.food.base.repo.entity.UserRecipeStepRemark
+import com.develop.food.base.repo.entity.UserTag
 
 @Database(
     entities = [DevVersion::class, UserInfo::class, UserFavoriteRecipes::class, UserHistoryRecipes::class, UserTag::class, UserOnLineRecipes::class,UserRecipeStepRemark::class],

+ 3 - 2
libBase/src/main/java/com/develop/food/base/repo/db/dao/UserInfoDao.kt

@@ -1,6 +1,7 @@
 package com.develop.food.base.repo.db.dao
 
 import androidx.room.*
+import com.develop.food.base.repo.CURRENT_USER_ID
 import com.develop.food.base.repo.entity.*
 
 @Dao
@@ -51,8 +52,8 @@ interface UserInfoDao {
     @Query("Delete from user_online_recipes where onLineRecipesId =:onLineRecipesId and userId = :userId")
     fun removeOnlineRecipe(userId: Long, onLineRecipesId: String)
 
-    @Query("select * from user_online_recipes")
-    fun queryUserOnLineRecipesIds(): List<UserOnLineRecipes>
+    @Query("select * from user_online_recipes where userId=:userId")
+    fun queryUserOnLineRecipesIds(userId: Long = CURRENT_USER_ID): List<UserOnLineRecipes>
 
     @Insert(onConflict = OnConflictStrategy.REPLACE)
     fun insertUserRecipeStepRemark(userRecipeStepRemark: UserRecipeStepRemark)