Browse Source

提交人:jtm
提交内容:bug fix

江天明 1 year ago
parent
commit
0d4ee7af9a

+ 7 - 1
BusinessCommon/src/main/java/com/develop/common/dialog/RecipeUpdateDialog.kt

@@ -1,5 +1,6 @@
 package com.develop.common.dialog
 
+import android.animation.ObjectAnimator
 import android.os.Bundle
 import android.view.LayoutInflater
 import android.view.View
@@ -39,6 +40,11 @@ class RecipeUpdateDialog() : FullScreenTransparentDialog() {
             removeSelf()
         }
 
+        //利用ObjectAnimator实现旋转动画
+        binding.loading.pivotX = (binding.loading.width / 2).toFloat();
+        binding.loading.pivotY = (binding.loading.height / 2).toFloat()
+        ObjectAnimator.ofFloat(binding.loading, "rotation", 0f, 360f).setDuration(1000).start();
+
         if (type == "UPDATE_TIPS") {
             binding.tvMsg.text = msg
             binding.tvCancel.visibility = View.VISIBLE;
@@ -88,7 +94,7 @@ class RecipeUpdateDialog() : FullScreenTransparentDialog() {
             msg = getString(R.string.no_recipe_update_tips)
         }
         type = "NO_UPDATE"
-        showDialog(manager,tag)
+        showDialog(manager, tag)
     }
 
     fun showUpdating(

+ 4 - 0
BusinessCommon/src/main/java/com/develop/common/event/CommonEvent.kt

@@ -3,7 +3,11 @@ package com.develop.common.event
 
 class FinishAtyEvent() {
 }
+
 class RefreshDataEvent {}
+class RefreshLikeDataEvent(var isLike: Boolean, var recipeNumber: String) {}
+
+class RefreshStarDataEvent(var starCount: Int, var recipeNumber: String) {}
 
 data class CookStepEvent(
     var recipeNumber: String = "",

+ 1 - 0
BusinessCommon/src/main/java/com/develop/common/food_sdk/FloatWindowManager.kt

@@ -10,6 +10,7 @@ import com.blankj.utilcode.util.ScreenUtils.getScreenWidth
 import com.develop.base.ext.globalApp
 import com.develop.base.ext.navigateTo
 import com.develop.base.ext.resId2Dimension
+import com.develop.base.ext.src
 import com.develop.base.util.ThreadUtils
 import com.develop.common.R
 import com.develop.common.dialog.CancelConfirmDialog

+ 1 - 1
BusinessCommon/src/main/java/com/develop/common/food_sdk/ProtocolListener.kt

@@ -30,7 +30,7 @@ class ProtocolListener(private val serialPort: SerialPort) : Runnable {
                                     cmd[i] = bytes[i]
                                 }
                                 val baseDecoder = BaseDecoder(cmd)
-                                Log.i("mcu2dev:", baseDecoder.escapeBytesStr())
+                              //  Log.i("mcu2dev:", baseDecoder.escapeBytesStr())
                                 if ("0001" == baseDecoder.protocol) {
                                     Log.i("ShakeHandsCmd:", baseDecoder.escapeBytesStr())
 

+ 5 - 4
BusinessCommon/src/main/java/com/develop/common/widget/FoodContentView.kt

@@ -30,6 +30,7 @@ import com.develop.common.data_repo.db.entity.UserFavoriteRecipes
 import com.develop.common.databinding.FoodContentViewBinding
 import com.develop.common.dialog.CancelConfirmDialog
 import com.develop.common.event.RefreshDataEvent
+import com.develop.common.event.RefreshLikeDataEvent
 import com.develop.common.router.Screens
 import com.develop.common.tag.*
 import com.drake.net.utils.scope
@@ -125,14 +126,14 @@ class FoodContentView : ConstraintLayout {
                 } else {
                     if (isLike) {
                         isLike = false
-                        binding.ivLike.skinSrc( R.drawable.ic_unlike)
+                        binding.ivLike.skinSrc(R.drawable.ic_unlike)
                         FoodDataProvider.getUserDatabase().runInTransaction {
                             FoodDataProvider.getUserDatabase().userInfoDao().removeFavoriteRecipe(
                                 CURRENT_USER_ID, foodId
                             )
                         }
                         if (!mIsHistoryList) {
-                            EventBus.getDefault().post(RefreshDataEvent())
+                            EventBus.getDefault().post(RefreshLikeDataEvent(false, foodId))
                         }
 
                     } else {
@@ -144,7 +145,7 @@ class FoodContentView : ConstraintLayout {
                             )
                         }
                         if (!mIsHistoryList) {
-                            EventBus.getDefault().post(RefreshDataEvent())
+                            EventBus.getDefault().post(RefreshLikeDataEvent(true, foodId))
                         }
                     }
                 }
@@ -197,7 +198,7 @@ class FoodContentView : ConstraintLayout {
                 ivLike.skinSrc(R.drawable.ic_delete)
             } else {
                 if (isLike) {
-                    ivLike.skinSrc( R.drawable.ic_like)
+                    ivLike.skinSrc(R.drawable.ic_like)
                 } else {
                     ivLike.skinSrc(R.drawable.ic_unlike)
                 }

+ 1 - 1
BusinessCommon/src/main/res/layout/dialog_recipe_update.xml

@@ -10,7 +10,7 @@
         android:layout_width="@dimen/convert_500px"
         android:layout_height="wrap_content"
         android:layout_gravity="center"
-        android:background="@drawable/bg_white_button"
+        android:background="@drawable/bg_white_button_round10px"
         android:paddingStart="@dimen/convert_37px"
         android:paddingTop="@dimen/convert_87px"
         android:paddingEnd="@dimen/convert_37px"

+ 35 - 0
BusinessMain/src/main/java/com/develop/main/ui/RecipesFragment.kt

@@ -33,6 +33,8 @@ import com.develop.common.data_repo.db.entity.DevRecipeCategory
 import com.develop.common.databinding.FragmentCommeListBinding
 import com.develop.common.dialog.LoadingDialog
 import com.develop.common.event.RefreshDataEvent
+import com.develop.common.event.RefreshLikeDataEvent
+import com.develop.common.event.RefreshStarDataEvent
 import com.develop.common.router.Screens
 import com.develop.common.tag.*
 import com.develop.common.ui.CommonBVMFragment
@@ -454,6 +456,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
                     //从网络菜谱切回本地菜谱,更新数据
                     viewModel.recipesType = RecipesType.LOCAL
                 }
+                filterSortSearchView?.updateHotWord("")
                 refreshOnLineOrLocalRecipes()
             }
             //获取本地菜谱分类回调
@@ -650,4 +653,36 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
         fromRefreshEvent = true
         refreshOnLineOrLocalRecipes()
     }
+
+    @Subscribe
+    fun refreshLikeRecipes(event: RefreshLikeDataEvent) {
+        val dataList = binding.rv.bindingAdapter._data ?: arrayListOf()
+        for (i in dataList.indices) {
+            val data = dataList[i]
+            if (data is FoodContentModel) {
+                if (data.foodId == event.recipeNumber) {
+                    data.isLike = event.isLike
+                    binding.rv.bindingAdapter._data = dataList
+                    binding.rv.bindingAdapter.notifyItemChanged(i)
+                }
+            }
+        }
+
+    }
+
+    @Subscribe
+    fun refreshStarRecipes(event: RefreshStarDataEvent) {
+        val dataList = binding.rv.bindingAdapter._data ?: arrayListOf()
+        for (i in dataList.indices) {
+            val data = dataList[i]
+            if (data is FoodContentModel) {
+                if (data.foodId == event.recipeNumber) {
+                    data.starCount = event.starCount
+                    binding.rv.bindingAdapter._data = dataList
+                    binding.rv.bindingAdapter.notifyItemChanged(i)
+                }
+            }
+        }
+
+    }
 }

+ 20 - 11
BusinessSetting/src/main/java/com/develop/setting/ui/RestoreActivity.kt

@@ -6,11 +6,15 @@ import android.os.PowerManager
 import android.view.LayoutInflater
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.develop.base.ext.updateText
+import com.develop.base.scop.safeGlobalScope
 import com.develop.common.data_repo.FoodDataProvider
 import com.develop.common.router.Screens
 import com.develop.common.ui.CommonBindingActivity
 import com.develop.common.dialog.CancelConfirmDialog
 import com.develop.setting.databinding.ActivityRestoreBinding
+import com.drake.net.utils.withMain
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
 import java.io.File
 
 @Route(path = Screens.Setting.RESTORE)
@@ -30,20 +34,25 @@ class RestoreActivity : CommonBindingActivity<ActivityRestoreBinding>() {
         dialog.title = getString(com.develop.common.R.string.restore_confirm_tips)
         dialog.onDialogClickListener = object : CancelConfirmDialog.OnDialogClickListener {
             override fun onConfirm() {
-                FoodDataProvider.deleteAll()
-                val cacheDirectory = cacheDir
-                val applicationDirectory = cacheDirectory.parent?.let { File(it) }
-                if (applicationDirectory?.exists() == true) {
-
-                    val files = applicationDirectory.listFiles() ?: emptyArray()
-                    for (file in files) {
-                        if (!file.name.equals("lib")) {
-                            com.blankj.utilcode.util.FileUtils.delete(file)
+                safeGlobalScope.launch(Dispatchers.IO) {
+                    FoodDataProvider.deleteAll()
+                    val cacheDirectory = cacheDir
+                    val applicationDirectory = cacheDirectory.parent?.let { File(it) }
+                    if (applicationDirectory?.exists() == true) {
+
+                        val files = applicationDirectory.listFiles() ?: emptyArray()
+                        for (file in files) {
+                            if (!file.name.equals("lib")) {
+                                com.blankj.utilcode.util.FileUtils.delete(file)
+                            }
                         }
                     }
+                    withMain {
+                        val pm = getSystemService(Context.POWER_SERVICE) as PowerManager
+                        pm.reboot("")
+                    }
                 }
-                val pm = getSystemService(Context.POWER_SERVICE) as PowerManager
-                pm.reboot("")
+
             }
 
             override fun onCancel() {

+ 1 - 1
BusinessSetting/src/main/res/layout/activity_about.xml

@@ -98,7 +98,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_centerVertical="true"
-                android:layout_marginStart="@dimen/convert_43px"
+                android:layout_marginStart="@dimen/convert_23px"
                 android:text="@string/apk"
                 android:textColor="@color/about_function_title"
                 android:textSize="@dimen/convert_30px" />

+ 9 - 1
BusinessStep/src/main/java/com/develop/step/ui/FoodListActivity.kt

@@ -12,6 +12,7 @@ import com.develop.common.router.Screens
 import com.develop.common.ui.CommonBVMActivity
 import com.develop.common.widget.FoodContentView
 import com.develop.common.R
+import com.develop.common.dialog.LoadingDialog
 import com.develop.common.tag.*
 import com.develop.step.databinding.ActivityFoodListBinding
 import com.develop.step.viewmodel.FoodListViewModel
@@ -33,12 +34,18 @@ class FoodListActivity : CommonBVMActivity<ActivityFoodListBinding, FoodListView
         return ActivityFoodListBinding.inflate(inflater)
     }
 
+
+    private val loadingDialog by lazy {
+        LoadingDialog()
+    }
+
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         val bundle = intent.extras
         binding.ivClose.setOnClickListener {
             finish()
         }
+        loadingDialog.showDialog(supportFragmentManager, "loadingDialog")
         viewModel.foodListType = bundle?.getInt(FOOD_LIST_TYPE) ?: Favourite
         title = bundle?.getString(FOOL_LIST_TITLE) ?: ""
         binding.tvTitle.updateText(title)
@@ -56,6 +63,7 @@ class FoodListActivity : CommonBVMActivity<ActivityFoodListBinding, FoodListView
         }.models = viewModel.foodListLiveData.value
 
         viewModel.foodListLiveData.observe(this) {
+            loadingDialog.removeSelf()
             binding.foodListRecycler.models = it
             if (viewModel.foodListType == Downloaded) {
                 binding.tvTitle.updateText("$title(${it.size})")
@@ -75,7 +83,7 @@ class FoodListActivity : CommonBVMActivity<ActivityFoodListBinding, FoodListView
 
     override fun onDestroy() {
         super.onDestroy()
-
+        loadingDialog.removeSelf()
     }
 
     companion object {

+ 2 - 2
BusinessStep/src/main/java/com/develop/step/ui/cook_step/CookStepBaseActivity.kt

@@ -328,12 +328,12 @@ abstract class CookStepBaseActivity :
 
     fun updateDirection(directionValue: Int) {
         if (directionValue == 0) {
-            binding.controller.ivDirection.rotation = 180f
+            binding.controller.ivDirection.rotationY = 180f
             binding.controller.tvTurnRight.setTextColor(0xffE5E5E5.toInt())
             binding.controller.tvTurnLeft.setTextColor(0xffE60012.toInt())
             binding.controller.tvSetDirection.updateText(getString(R.string.turn_right))
         } else {
-            binding.controller.ivDirection.rotation = 0f
+            binding.controller.ivDirection.rotationY = 0f
             binding.controller.tvTurnRight.setTextColor(0xffE60012.toInt())
             binding.controller.tvTurnLeft.setTextColor(0xffE5E5E5.toInt())
             binding.controller.tvSetDirection.updateText(getString(R.string.turn_left))

+ 5 - 1
BusinessStep/src/main/java/com/develop/step/ui/recipes_detail/CookDetailActivity.kt

@@ -25,6 +25,7 @@ import com.develop.common.utils.Resource
 import com.develop.common.dialog.DownloadFailedDialog
 import com.develop.common.dialog.ShareQRCodeDialog
 import com.develop.common.event.RefreshDataEvent
+import com.develop.common.event.RefreshLikeDataEvent
 import com.develop.common.utils.setLeftDrawable
 import com.develop.step.databinding.ActivityCookDetailBinding
 import com.develop.step.viewmodel.CookDetailViewModel
@@ -229,7 +230,9 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
                     FoodDataProvider.getUserDatabase().userInfoDao().removeFavoriteRecipe(
                         CURRENT_USER_ID, recipeNumber ?: ""
                     )
+                    EventBus.getDefault().post(RefreshLikeDataEvent(false, recipeNumber ?: ""))
                 }
+
                 binding.viewLike.src = com.develop.common.R.drawable.ic_unlike
             } else {
                 isLike = true
@@ -238,6 +241,7 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
                     FoodDataProvider.getUserDatabase().userInfoDao().insertFavoriteRecipe(
                         UserFavoriteRecipes(CURRENT_USER_ID, recipeNumber ?: "")
                     )
+                    EventBus.getDefault().post(RefreshLikeDataEvent(true, recipeNumber ?: ""))
                 }
             }
         }
@@ -260,7 +264,7 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
             binding.tvMoreScore.textSize = dp5
             binding.tvMoreDelete.textSize = dp5
             binding.tvMoreShare.textSize = dp5
-            binding.moreContainer.setPadding(dp20,dp20,0,dp20)
+            binding.moreContainer.setPadding(dp20, dp20, 0, dp20)
 
         }
 

+ 2 - 1
BusinessStep/src/main/java/com/develop/step/ui/recipes_detail/CookEvaluateActivity.kt

@@ -15,6 +15,7 @@ import com.develop.common.tag.CURRENT_USER_ID
 import com.develop.common.ui.CommonBindingActivity
 import com.develop.common.R
 import com.develop.common.event.RefreshDataEvent
+import com.develop.common.event.RefreshStarDataEvent
 
 import com.develop.step.databinding.ActivityCookEvaluateBinding
 import org.greenrobot.eventbus.EventBus
@@ -91,7 +92,7 @@ class CookEvaluateActivity : CommonBindingActivity<ActivityCookEvaluateBinding>(
                 }
 
             }
-            EventBus.getDefault().post(RefreshDataEvent())
+            EventBus.getDefault().post(RefreshStarDataEvent(starCount, recipeId))
             GlobalToast.showToast("Evaluate successfully")
 
         }

+ 4 - 4
BusinessStep/src/main/res/layout/activity_cook_step_base.xml

@@ -84,17 +84,17 @@
 
     <TextView
         android:id="@+id/tv_step_name"
-        android:layout_width="@dimen/convert_479px"
-        android:layout_height="@dimen/convert_280px"
+        android:layout_width="@dimen/convert_679px"
+        android:layout_height="@dimen/convert_580px"
         android:text="Step1:Peel 3 onions(180g)and2garlic cloves,halve the onions andput both in the blender jug."
         android:textColor="#fff"
         android:layout_marginStart="@dimen/convert_40px"
         android:layout_marginTop="@dimen/convert_40px"
         android:layout_marginEnd="@dimen/convert_99px"
         android:textSize="@dimen/convert_26px"
-        android:lineSpacingExtra="10dp"
+        android:lineSpacingExtra="@dimen/convert_10px"
         android:ellipsize="end"
-        android:maxLines="4"
+        android:maxLines="5"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toBottomOf="@+id/cl_status_bar"/>