Browse Source

处理030涂鸦访问

zhangshenjie 3 weeks ago
parent
commit
7a63c1e853

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

@@ -17,6 +17,7 @@ import com.bumptech.glide.request.RequestListener
 import com.bumptech.glide.request.target.Target
 import com.develop.base.ext.background_drawable
 import com.develop.base.ext.getGoneScore
+import com.develop.base.ext.getNewTuya
 import com.develop.base.ext.getSN
 import com.develop.base.ext.isRecipesList
 import com.develop.base.ext.load
@@ -129,7 +130,7 @@ class FoodContentView : ConstraintLayout {
             //收藏/取消收藏
             mFoodContent?.apply {
                 if (isNetRecipes && mIsFoodList) {
-                    if (foodSn.startsWith("011")) {
+                    if (getNewTuya()) {
                         if (isLike) {
                             EventBus.getDefault().post(OnLikeDataEvent(false, foodId))
                         } else {
@@ -184,7 +185,7 @@ class FoodContentView : ConstraintLayout {
                     }
                 } else {
                     if (isLike) {
-                        if (foodSn.startsWith("011")) {
+                        if (getNewTuya()) {
                             EventBus.getDefault().post(OnLikeDataEvent(false, foodId))
                         } else {
                             isLike = false
@@ -205,7 +206,7 @@ class FoodContentView : ConstraintLayout {
                             EventBus.getDefault().post(RefreshLikeDataEvent(false, foodId))
                         }
                     } else {
-                        if (foodSn.startsWith("011")) {
+                        if (getNewTuya()) {
                             EventBus.getDefault().post(OnLikeDataEvent(true, foodId))
                         } else {
                             isLike = true

+ 11 - 10
BusinessMain/src/main/java/com/develop/main/ui/RecipesFragment.kt

@@ -21,6 +21,7 @@ import com.bumptech.glide.Glide
 import com.develop.base.ext.background_color
 import com.develop.base.ext.background_drawable
 import com.develop.base.ext.getModelNum
+import com.develop.base.ext.getNewTuya
 import com.develop.base.ext.getSN
 import com.develop.base.ext.globalApp
 import com.develop.base.ext.isBrand011A
@@ -249,7 +250,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
                                     if (viewModel.recipesType == RecipesType.ONLINE) {
                                         updateFilterName(viewModel.currCategoryName)
                                     } else {
-                                        if (sn.startsWith("011")) {
+                                        if (getNewTuya()) {
                                             updateFilterName(viewModel.currCategoryName)
 
                                         } else {
@@ -274,7 +275,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
 
                             //分类名称
                             val categoryName =
-                                if (sn.startsWith("011")) viewModel.currCategoryName else model.category
+                                if (getNewTuya()) viewModel.currCategoryName else model.category
                             val tvCategoryName =
                                 findView<AppCompatTextView>(R.id.tv_food_category_name)
                             if (categoryName != null&&!viewModel.isSearch) {
@@ -290,7 +291,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
                             /**
                              * 由于刷新列表,需要在再走一遍创建,故写一个letterPosition 记录位置
                              * */
-                            if (!sn.startsWith("011")) {
+                            if (!getNewTuya()) {
                                 val letterRv =
                                     findView<RecyclerView>(com.develop.common.R.id.letter_rv)
                                 if (categoryName != null && viewModel.recipesType != RecipesType.ONLINE) {
@@ -352,7 +353,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
                             val categoryTabViewLayout =
                                 findView<CategoryTabViewLayout>(R.id.category_tab_view)
                             if (categoryModel != null) {
-                                if (sn.startsWith("011")){
+                                if (getNewTuya()){
                                     categoryTabViewLayout.setGone()
                                 }else{
                                     categoryTabViewLayout.setVisible()
@@ -432,7 +433,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
                             finishLoadMoreWithNoMoreData()
                         }
                     } else {
-                        if (sn.startsWith("011")){
+                        if (getNewTuya()){
                             viewModel.loadMoreLocal011Recipes()
                         }else{
                             if (!viewModel.loadMoreLocalRecipes()) {
@@ -450,7 +451,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
                             finishLoadMoreWithNoMoreData()
                         }
                     } else {
-                        if (sn.startsWith("011")){
+                        if (getNewTuya()){
                             viewModel.loadMoreLocal011Recipes()
                         }else{
                             if (!viewModel.loadMoreLocalRecipes()) {
@@ -639,7 +640,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
                 if (viewModel.recipesType == RecipesType.ONLINE) {
                     binding.tvName.updateText(name)
                 } else {
-                    if (viewModel.snModel.startsWith("011")) {
+                    if (getNewTuya()) {
                         binding.tvName.updateText(name)
                     } else {
                         binding.tvName.updateText("$name($size)")
@@ -662,7 +663,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
             binding.itemLayout.setOnClickListener {
                 //处理011分页问题
                 //点击分类重新初始 0 页
-                if (sn.startsWith("011")){
+                if (getNewTuya()){
                     viewModel.pageNo = 0
                     recipesList.clear()
                 }
@@ -978,7 +979,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
             if (viewModel.recipesType == RecipesType.ONLINE) {
                 updateFilterName(viewModel.currCategoryName)
             } else {
-                if (sn.startsWith("011")) {
+                if (getNewTuya()) {
                     updateFilterName(viewModel.currCategoryName)
                 }
             }
@@ -1065,7 +1066,7 @@ class RecipesFragment : CommonBVMFragment<FragmentCommeListBinding, HomeViewMode
             } else {
                 isRefresh = true
                 binding.page.resetNoMoreData()
-                if (sn.startsWith("011")){
+                if (getNewTuya()){
                     if (viewModel.categoryCode == globalApp().getString(com.develop.common.R.string.all)) {
                         viewModel.queryLocalRecipes("")
                     } else {

+ 4 - 3
BusinessMain/src/main/java/com/develop/main/viewmodel/HomeViewModel.kt

@@ -6,6 +6,7 @@ import android.util.Log
 import androidx.annotation.RequiresApi
 import androidx.lifecycle.MutableLiveData
 import androidx.lifecycle.scopeNetLife
+import com.develop.base.ext.getNewTuya
 import com.develop.base.ext.getSN
 import com.develop.base.ext.globalApp
 import com.develop.base.mvvm.BaseViewModel
@@ -125,7 +126,7 @@ class HomeViewModel : BaseViewModel() {
     @SuppressLint("SuspiciousIndentation")
     @RequiresApi(Build.VERSION_CODES.N)
     fun queryRecipesCategory() {
-        if (snModel.startsWith("011")) {
+        if (getNewTuya()) {
             var lang = MMkvUtils.getString(CURRENT_LANGUAGE) ?: "en"
             var map = HashMap<String, Any>()
             map["lang"] = lang
@@ -244,7 +245,7 @@ class HomeViewModel : BaseViewModel() {
 
     /**查询本地对应菜谱分类下的菜谱列表信息*/
     fun queryLocalRecipes(categoryNum: String) {
-        if (snModel.startsWith("011")) {
+        if (getNewTuya()) {
             categoryRecipesNum = categoryNum
             var lang = MMkvUtils.getString(CURRENT_LANGUAGE) ?: "en"
             var orderType = if (sortedType == SortedType.A2Z) 1 else 2
@@ -500,7 +501,7 @@ class HomeViewModel : BaseViewModel() {
 
     /**根据热词查询菜谱列表信息*/
     fun queryRecipesByHotWord(hotWord: String, categoryType: CategoryType) {
-        if (snModel.startsWith("011")) {
+        if (getNewTuya()) {
             searchHotWord = hotWord
             var lang = MMkvUtils.getString(CURRENT_LANGUAGE) ?: "en"
 //            var orderType = if (sortedType == SortedType.A2Z) 1 else 2

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

@@ -145,7 +145,7 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
             recipesloadingDialog.removeSelf()
         }
         viewModel.getRecipeLiveData().observe(this) {
-            if (baseSn.startsWith("011")){
+            if (getNewTuya()){
                 recipesloadingDialog.removeSelf()
             }
 
@@ -187,7 +187,7 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
         }
 
         viewModel.addLikeLiveData.observe(this) {
-            if (baseSn.startsWith("011")){
+            if (getNewTuya()){
                 recipesloadingDialog.removeSelf()
             }
 
@@ -203,7 +203,7 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
 
 
         viewModel.deleteLikeLiveData.observe(this) {
-            if (baseSn.startsWith("011")){
+            if (getNewTuya()){
                 recipesloadingDialog.removeSelf()
             }
 
@@ -494,7 +494,7 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
         binding.viewLike.setOnClickListener {
             //收藏/取消收藏
             if (isLike) {
-                if (baseSn.startsWith("011")) {
+                if (getNewTuya()) {
                     viewModel.deleteLikeRecipes(recipeNumber ?: "")
                     recipesloadingDialog.showDialog(supportFragmentManager, "loadingDialog")
                 } else {
@@ -512,7 +512,7 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
 
 
             } else {
-                if (baseSn.startsWith("011")){
+                if (getNewTuya()){
                     viewModel.addLikeRecipes(recipeNumber ?: "")
                     recipesloadingDialog.showDialog(supportFragmentManager, "loadingDialog")
                 }else{
@@ -830,7 +830,7 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
                     it
                 }
 
-                if (sn.startsWith("011")) {
+                if (getNewTuya()) {
                     binding.tvEasy.text = detail.recipe.difficultyLevel
 
                 } else {
@@ -847,7 +847,7 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
         }
 
         binding.startLayout.setCommentNumber(detail.recipe.useNum.toString())
-        if (baseSn.startsWith("011")) {
+        if (getNewTuya()) {
             if (isLike) {
                 binding.viewLike.src = com.develop.common.R.drawable.ic_like
             } else {
@@ -944,7 +944,7 @@ class CookDetailActivity : CommonBVMActivity<ActivityCookDetailBinding, CookDeta
         super.onResume()
         viewModel.getStarCount(recipeNumber ?: "")
         if (isOnResume) {
-            if (baseSn.startsWith("011")&&isLoadingType){
+            if (getNewTuya() &&isLoadingType){
                 recipesloadingDialog.showDialog(supportFragmentManager, "loadingDialog")
                 isLoadingType = false
             }

+ 2 - 1
BusinessStep/src/main/java/com/develop/step/viewmodel/CookDetailViewModel.kt

@@ -7,6 +7,7 @@ import com.blankj.utilcode.util.FileUtils
 import com.blankj.utilcode.util.GsonUtils
 import com.blankj.utilcode.util.ToastUtils
 import com.blankj.utilcode.util.ZipUtils
+import com.develop.base.ext.getNewTuya
 import com.develop.base.ext.getSN
 import com.develop.base.ext.globalApp
 import com.develop.base.mvvm.BaseViewModel
@@ -72,7 +73,7 @@ class CookDetailViewModel : BaseViewModel() {
      *          [DevRecipePortionSize] 食谱原料用量
      */
     fun queryRecipe(number: String, remote: Boolean, recipesEdition: String) {
-        if (sn.startsWith("011")) {
+        if (getNewTuya()) {
             var lang = MMkvUtils.getString(CURRENT_LANGUAGE) ?: "en"
 
             var map = HashMap<String, Any>()

+ 2 - 1
BusinessStep/src/main/java/com/develop/step/viewmodel/FoodListViewModel.kt

@@ -2,6 +2,7 @@ package com.develop.step.viewmodel
 
 import androidx.lifecycle.MutableLiveData
 import androidx.lifecycle.scopeLife
+import com.develop.base.ext.getNewTuya
 import com.develop.base.ext.getSN
 import com.develop.base.ext.globalApp
 import com.develop.base.mvvm.BaseViewModel
@@ -44,7 +45,7 @@ class FoodListViewModel : BaseViewModel() {
     }
 
     private fun getFavoriteOrHistoryFoodList(foodListType: Int) = scopeLife(Dispatchers.IO) {
-        if (getSN().startsWith("011")) {
+        if (getNewTuya()) {
             if (foodListType == History) {
                 getHistoryList()
             } else {

+ 7 - 0
libBase/src/main/java/com/develop/base/ext/GlobaExt.kt

@@ -46,6 +46,8 @@ fun globalApp(): Application = BaseApp.application
 
 fun globalRes(): Resources = globalApp().resources
 
+private  var sn = getSN()
+
 // ------------------------------Any扩展-------------------------------------
 fun Any.toJson(): String = Json.encodeToString(this)
 
@@ -348,6 +350,11 @@ fun getGoneScore(): Boolean {
             || sn.startsWith("083A") || sn.startsWith("083B")
 }
 
+//需要新版涂鸦功能
+fun  getNewTuya():Boolean{
+    return sn.startsWith("011") || sn.startsWith("030")
+}
+
 
 //隐藏涂鸦
 fun getGoneTuYa(): Boolean {