Browse Source

提交人:jtm
提交内容:优化显示内容

江天明 1 year ago
parent
commit
44525296f9

+ 70 - 68
BusinessCommon/src/main/java/com/develop/common/widget/FoodContentView.kt

@@ -73,7 +73,76 @@ class FoodContentView : RelativeLayout {
                 }
             }
         }
+        //喜欢点击
+        binding.likeLayout.setOnClickListener {
+            //收藏/取消收藏
+            mFoodContent?.apply {
+                if (isNetRecipes && mIsFoodList) {
+                    val titleStr = context.getString(R.string.are_you_sure_to_delete)
+                    val confirmStr = context.getString(R.string.yes)
+                    val cancelStr = context.getString(R.string.no)
+                    TopResumedAtyHolder.getCurrentActivity()?.apply {
+                        cancelConfirmDialog.apply {
+                            this.title = titleStr
+                            this.confirmStr = confirmStr
+                            this.cancelStr = cancelStr
+                            onDialogClickListener =
+                                object : CancelConfirmDialog.OnDialogClickListener {
+                                    override fun onConfirm() {
+                                        FoodDataProvider.getUserDatabase().runInTransaction {
+                                            FoodDataProvider.getUserDatabase().userInfoDao()
+                                                .removeOnlineRecipe(
+                                                    CURRENT_USER_ID, foodId
+                                                )
+                                        }
+                                        FoodDataProvider.getDatabase().runInTransaction {
+                                            val recipeDao =
+                                                FoodDataProvider.getDatabase().recipeDao()
+                                            val recipes = recipeDao.queryRecipe(foodId)
+                                            recipes?.apply {
+                                                recipeDao.deleteRecipe(this)
+                                            }
+                                            FoodDataProvider.deleteRecipeResource(foodId)
+                                        }
+                                        EventBus.getDefault().post(RefreshDataEvent())
+                                    }
+
+                                    override fun onCancel() {
+
+                                    }
+                                }
+                            showDialog(supportFragmentManager, "cancelConfirmDialog")
+                        }
+                    }
+                } else {
+                    if (isLike) {
+                        isLike = false
+                        binding.ivLike.src = R.drawable.ic_unlike
+                        FoodDataProvider.getUserDatabase().runInTransaction {
+                            FoodDataProvider.getUserDatabase().userInfoDao().removeFavoriteRecipe(
+                                CURRENT_USER_ID, foodId
+                            )
+                        }
+                        if (!mIsHistoryList) {
+                            EventBus.getDefault().post(RefreshDataEvent())
+                        }
+
+                    } else {
+                        isLike = true
+                        binding.ivLike.src = R.drawable.ic_like
+                        FoodDataProvider.getUserDatabase().runInTransaction {
+                            FoodDataProvider.getUserDatabase().userInfoDao().insertFavoriteRecipe(
+                                UserFavoriteRecipes(CURRENT_USER_ID, foodId)
+                            )
+                        }
+                        if (!mIsHistoryList) {
+                            EventBus.getDefault().post(RefreshDataEvent())
+                        }
+                    }
+                }
+            }
 
+        }
     }
 
     /**
@@ -100,7 +169,7 @@ class FoodContentView : RelativeLayout {
             }
         }
         binding.apply {
-            if ("" != cover) ivCover.load(cover)
+            if ("" != cover) ivCover.load(cover, binding.ivCover.width, binding.ivCover.height)
             tvFoodName.updateText(content.foodName)
             scope(Dispatchers.IO) {
                 val result = FoodDataProvider.getUserDatabase().userInfoDao()
@@ -130,74 +199,7 @@ class FoodContentView : RelativeLayout {
                     ivLike.src = R.drawable.ic_unlike
                 }
             }
-            //喜欢点击
-            likeLayout.setOnClickListener {
-                //收藏/取消收藏
-
-                if (content.isNetRecipes && isFoodList) {
-                    val titleStr = context.getString(R.string.are_you_sure_to_delete)
-                    val confirmStr = context.getString(R.string.yes)
-                    val cancelStr = context.getString(R.string.no)
-                    TopResumedAtyHolder.getCurrentActivity()?.apply {
-                        cancelConfirmDialog.apply {
-                            this.title = titleStr
-                            this.confirmStr = confirmStr
-                            this.cancelStr = cancelStr
-                            onDialogClickListener =
-                                object : CancelConfirmDialog.OnDialogClickListener {
-                                    override fun onConfirm() {
-                                        FoodDataProvider.getUserDatabase().runInTransaction {
-                                            FoodDataProvider.getUserDatabase().userInfoDao()
-                                                .removeOnlineRecipe(
-                                                    CURRENT_USER_ID, content.foodId
-                                                )
-                                        }
-                                        FoodDataProvider.getDatabase().runInTransaction {
-                                            val recipeDao =
-                                                FoodDataProvider.getDatabase().recipeDao()
-                                            val recipes = recipeDao.queryRecipe(content.foodId)
-                                            recipes?.apply {
-                                                recipeDao.deleteRecipe(this)
-                                            }
-                                            FoodDataProvider.deleteRecipeResource(content.foodId)
-                                        }
-                                        EventBus.getDefault().post(RefreshDataEvent())
-                                    }
 
-                                    override fun onCancel() {
-
-                                    }
-                                }
-                            showDialog(supportFragmentManager, "cancelConfirmDialog")
-                        }
-                    }
-                } else {
-                    if (content.isLike) {
-                        content.isLike = false
-                        ivLike.src = R.drawable.ic_unlike
-                        FoodDataProvider.getUserDatabase().runInTransaction {
-                            FoodDataProvider.getUserDatabase().userInfoDao().removeFavoriteRecipe(
-                                CURRENT_USER_ID, content.foodId
-                            )
-                        }
-                        if (!mIsHistoryList) {
-                            EventBus.getDefault().post(RefreshDataEvent())
-                        }
-
-                    } else {
-                        content.isLike = true
-                        ivLike.src = R.drawable.ic_like
-                        FoodDataProvider.getUserDatabase().runInTransaction {
-                            FoodDataProvider.getUserDatabase().userInfoDao().insertFavoriteRecipe(
-                                UserFavoriteRecipes(CURRENT_USER_ID, content.foodId)
-                            )
-                        }
-                        if (!mIsHistoryList) {
-                            EventBus.getDefault().post(RefreshDataEvent())
-                        }
-                    }
-                }
-            }
         }
     }
 

+ 2 - 2
BusinessCommon/src/main/res/layout/direction_view.xml

@@ -24,7 +24,7 @@
             android:layout_weight="1"
             android:gravity="center"
             android:paddingStart="@dimen/convert_60px"
-            android:text="@string/turn_right"
+            android:text="@string/turn_left"
             android:textColor="#E60012"
             android:textSize="@dimen/convert_20px" />
 
@@ -35,7 +35,7 @@
             android:layout_weight="1"
             android:gravity="center"
             android:paddingEnd="@dimen/convert_60px"
-            android:text="@string/turn_left"
+            android:text="@string/turn_right"
             android:textColor="#ffffff"
             android:textSize="@dimen/convert_20px" />
     </LinearLayout>

+ 9 - 0
BusinessCommon/src/main/res/layout/food_content_night_provider.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<com.develop.common.widget.FoodContentView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/food_content_view"
+    android:layout_marginStart="@dimen/convert_10px"
+    android:layout_marginEnd="@dimen/convert_10px"
+    android:layout_height="@dimen/convert_330px"
+    android:layout_marginBottom="@dimen/convert_24px"
+    android:layout_width="match_parent" />

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

@@ -4,11 +4,11 @@
     android:id="@+id/page"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@color/bg_color"
     app:stateEnabled="true">
 
     <androidx.recyclerview.widget.RecyclerView
         android:id="@+id/rv"
+        app:stackFromEnd="true"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:overScrollMode="never" />

+ 1 - 1
BusinessCommon/src/main/res/values-fr/strings.xml

@@ -41,7 +41,7 @@ Nanfang plus client is an online information platform developed and operated by
     <string name="adapted_cooking">Programmes automatiques</string>
     <string name="scales">Balance</string>
     <string name="boil_water">BOIL WATER</string>
-    <string name="chop">Chop</string>
+    <string name="chop">Hacher</string>
     <string name="slow_cook">Mijoter</string>
     <string name="knead_dough">Pétrir</string>
     <string name="steam">Vapeur</string>

+ 24 - 23
BusinessMain/src/main/java/com/develop/main/ui/RecipesFragment.kt

@@ -2,10 +2,7 @@ package com.develop.main.ui
 
 
 import android.graphics.Color
-import android.media.metrics.Event
 import android.os.Bundle
-import android.util.Log
-import android.util.SparseIntArray
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
@@ -13,14 +10,13 @@ import android.widget.RelativeLayout
 import androidx.appcompat.widget.AppCompatTextView
 import androidx.cardview.widget.CardView
 import androidx.databinding.ViewDataBinding
-import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.RecyclerView
+import androidx.recyclerview.widget.SimpleItemAnimator
 import com.bumptech.glide.Glide
 import com.develop.base.ext.background_color
 import com.develop.base.ext.background_drawable
 import com.develop.base.ext.globalApp
 import com.develop.base.ext.isNightTheme
-import com.develop.base.ext.layout_width
 import com.develop.base.ext.navigateTo
 import com.develop.base.ext.resId2Dimension
 import com.develop.base.ext.text_color
@@ -36,20 +32,16 @@ import com.develop.common.tag.*
 import com.develop.common.ui.CommonBVMFragment
 import com.develop.common.widget.*
 import com.develop.main.R
-import com.develop.main.databinding.FoodGridViewBinding
 import com.develop.main.databinding.ItemFilterAndSortViewBinding
 import com.develop.main.viewmodel.HomeViewModel
 import com.drake.brv.BindingAdapter
-import com.drake.brv.listener.OnMultiStateListener
 import com.drake.brv.utils.*
-import com.drake.net.time.Interval
 import com.drake.net.utils.scopeNet
-import com.scwang.smart.refresh.layout.api.RefreshLayout
-import com.scwang.smart.refresh.layout.listener.OnMultiListener
 import kotlinx.coroutines.delay
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
 
+
 class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewModel>() {
 
     private var filterSortSearchView: HomeFilterSortSearchView? = null
@@ -155,6 +147,8 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
         sortDataList.addAll(DataFactory.genSortNameList(resources))
 
         binding.rv.apply {
+
+            (itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false
             background_color = com.develop.common.R.color.bg_color
             setHasFixedSize(true)
             isNestedScrollingEnabled = false
@@ -174,19 +168,23 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
                         foodRecycle?.setRecycledViewPool(recycledViewPool)
                         foodRecycle?.grid(4)
                         foodRecycle?.setup {
-                            addType<FoodContentModel>(com.develop.common.R.layout.food_content_provider)
-                            onBind {
-                                if (isNightTheme()) {
-                                    findView<CardView>(com.develop.common.R.id.recipes_layout).apply {
-                                        cardElevation = 0f
-                                        maxCardElevation = 0f
-                                    }
+                            if (isNightTheme()){
+                                addType<FoodContentModel>(com.develop.common.R.layout.food_content_night_provider)
+                                onBind {
+                                    findView<FoodContentView>(com.develop.common.R.id.food_content_view).setFoodContent(
+                                        getModel()
+                                    )
+                                }
+                            } else {
+                                addType<FoodContentModel>(com.develop.common.R.layout.food_content_provider)
+                                onBind {
+                                    findView<FoodContentView>(com.develop.common.R.id.food_content_view).setFoodContent(
+                                        getModel()
+                                    )
                                 }
-
-                                findView<FoodContentView>(com.develop.common.R.id.food_content_view).setFoodContent(
-                                    getModel()
-                                )
                             }
+
+
                         }
                     }
                 }
@@ -253,6 +251,8 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
             })
         }
         binding.page.apply {
+            setDisableContentWhenRefresh(true)
+            setDisableContentWhenLoading(true)
             setEnableRefresh(false)
             setEnableNestedScroll(false)
             setOnLoadMoreListener {
@@ -282,6 +282,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
         if (isNightTheme()){
             binding.footer.apply {
                 setPrimaryColor(Color.parseColor("#1A1A1A"))
+                setFinishDuration(0)
             }
         }
 
@@ -481,13 +482,13 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
             }
 
             moreLocalRecipeLiveData.observe(viewLifecycleOwner) {
-                foodRecycle?.addModels(it)
                 binding.page.finishLoadMore(true)
+                foodRecycle?.addModels(it)
             }
 
             moreSearchLocalRecipeLiveData.observe(viewLifecycleOwner) {
-                foodRecycle?.addModels(it)
                 binding.page.finishLoadMore(true)
+                foodRecycle?.addModels(it)
             }
 
             //获取线上分类回调

+ 12 - 6
BusinessStep/src/main/java/com/develop/step/ui/cook_step/CookStepActivity.kt

@@ -169,8 +169,10 @@ class CookStepActivity : CookStepBaseActivity() {
                     CofarSDK.stoptWeight()
                     viewModel.setDisplayStep(viewModel.stepIndex, force = true)
                 } else {
-                    binding.ivPrevStep.setGone()
-                    binding.ivNextStep.setGone()
+                   if (!isNightTheme()){
+                       binding.ivPrevStep.setGone()
+                       binding.ivNextStep.setGone()
+                   }
                     CofarSDK.changeMode(
                         "$recipeNumber:${viewModel.stepIndex}",
                         CofarSDK.devMode("WEIGHT")
@@ -193,8 +195,10 @@ class CookStepActivity : CookStepBaseActivity() {
                     CofarSDK.stoptWeight()
                     viewModel.setDisplayStep(viewModel.stepIndex, force = true)
                 } else {
-                    binding.ivPrevStep.setGone()
-                    binding.ivNextStep.setGone()
+                    if (!isNightTheme()){
+                        binding.ivPrevStep.setGone()
+                        binding.ivNextStep.setGone()
+                    }
                     CofarSDK.changeMode(
                         "$recipeNumber:${viewModel.stepIndex}",
                         CofarSDK.devMode("WEIGHT")
@@ -213,8 +217,10 @@ class CookStepActivity : CookStepBaseActivity() {
                     CofarSDK.stoptWeight()
                     viewModel.setDisplayStep(viewModel.stepIndex, force = true)
                 } else {
-                    binding.ivPrevStep.setGone()
-                    binding.ivNextStep.setGone()
+                    if (!isNightTheme()){
+                        binding.ivPrevStep.setGone()
+                        binding.ivNextStep.setGone()
+                    }
                     CofarSDK.changeMode(
                         "$recipeNumber:${viewModel.stepIndex}",
                         CofarSDK.devMode("TURBO")

+ 6 - 6
BusinessStep/src/main/res/layout/activity_mode_detail.xml

@@ -87,25 +87,25 @@
             >
 
             <ImageView
-                android:id="@+id/jiahao"
+                android:id="@+id/jianhao"
                 android:layout_width="@dimen/convert_50px"
                 android:layout_height="@dimen/convert_50px"
-                android:src="@drawable/jiahao"
+                android:src="@drawable/jianhao"
                 app:layout_constraintBottom_toBottomOf="parent"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintTop_toTopOf="parent"
-                app:layout_constraintVertical_bias="0.5"
+                app:layout_constraintVertical_bias="0.9"
                 />
 
             <ImageView
-                android:id="@+id/jianhao"
+                android:id="@+id/jiahao"
                 android:layout_width="@dimen/convert_50px"
                 android:layout_height="@dimen/convert_50px"
-                android:src="@drawable/jianhao"
+                android:src="@drawable/jiahao"
                 app:layout_constraintBottom_toBottomOf="parent"
                 app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintTop_toTopOf="parent"
-                app:layout_constraintHorizontal_bias="0.5"
+                app:layout_constraintVertical_bias="0.9"
                 />
         </androidx.constraintlayout.widget.ConstraintLayout>
 

+ 8 - 8
BusinessStep/src/main/res/layout/item_cook_controller.xml

@@ -17,25 +17,25 @@
         app:layout_constraintVertical_bias="0.32"
         >
         <ImageView
-            android:id="@+id/jiahao"
+            android:id="@+id/jianhao"
             android:layout_width="@dimen/convert_50px"
             android:layout_height="@dimen/convert_50px"
-            android:src="@drawable/jiahao"
+            android:src="@drawable/jianhao"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintTop_toTopOf="parent"
-            app:layout_constraintVertical_bias="0.5"
+            app:layout_constraintVertical_bias="0.9"
             />
 
         <ImageView
-            android:id="@+id/jianhao"
+            android:id="@+id/jiahao"
             android:layout_width="@dimen/convert_50px"
             android:layout_height="@dimen/convert_50px"
-            android:src="@drawable/jianhao"
+            android:src="@drawable/jiahao"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintTop_toTopOf="parent"
-            app:layout_constraintHorizontal_bias="0.5"
+            app:layout_constraintVertical_bias="0.9"
             />
     </androidx.constraintlayout.widget.ConstraintLayout>
 
@@ -159,7 +159,7 @@
                 android:layout_weight="1"
                 android:gravity="center"
                 android:paddingStart="@dimen/convert_60px"
-                android:text="@string/turn_right"
+                android:text="@string/turn_left"
                 android:textColor="@color/color_E60012"
                 android:textSize="@dimen/convert_20px" />
 
@@ -170,7 +170,7 @@
                 android:layout_weight="1"
                 android:gravity="center"
                 android:paddingEnd="@dimen/convert_60px"
-                android:text="@string/turn_left"
+                android:text="@string/turn_right"
                 android:textColor="@color/color_E5E5E5"
                 android:textSize="@dimen/convert_20px" />
         </LinearLayout>

+ 19 - 3
libBase/src/main/java/com/develop/base/ext/GlobaExt.kt

@@ -167,9 +167,10 @@ fun getWifiMacAddress(context: Context): String {
         return ""
     }
 
-    val wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
+    val wifiManager =
+        context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
     val wifiInfo: WifiInfo? = wifiManager.connectionInfo
-    return if(wifiInfo != null) wifiInfo.macAddress else ""
+    return if (wifiInfo != null) wifiInfo.macAddress else ""
 }
 
 /**
@@ -189,7 +190,12 @@ fun getSN(): String {
     append = (vi[1] + vi[0])
     try {
         serial = getWifiMacAddress(globalApp().applicationContext).uppercase()
-        return if (serial != "" && serial != "unknown") "${append}${serial.replace(":","")}" else "${append}8888"
+        return if (serial != "" && serial != "unknown") "${append}${
+            serial.replace(
+                ":",
+                ""
+            )
+        }" else "${append}8888"
     } catch (e: java.lang.Exception) {
         serial = "${append}8888"
     }
@@ -215,6 +221,16 @@ fun ImageView.load(data: Any?) {
         .into(this)
 }
 
+fun ImageView.load(data: Any?, width: Int, height: Int) {
+    Glide.with(this.context)
+        .asDrawable()
+        .load(data)
+        .diskCacheStrategy(DiskCacheStrategy.ALL)
+        .skipMemoryCache(true)
+        .override(width, height)
+        .into(this)
+}
+
 fun ImageView.load(data: Any?, error: Int) {
     Glide.with(this.context).load(data)
         .error(error)