From b2dc509d5530a9af3b48d7dce7db1e7bf66b06d5 Mon Sep 17 00:00:00 2001 From: Linjiajia <319408893@qq.com> Date: 星期三, 28 二月 2024 17:26:58 +0800 Subject: [PATCH] 1、修复新增家庭设备时存在备忘录问题\n2、旅游模块新增加“感言”、“其他费用”、“备注”字段 --- app/src/main/java/com/application/zhangshi_app_android/adapter/GrowthExperiencePrimaryRvAdapter.java | 111 ++++++++++++++++++++++++++----------------------------- 1 files changed, 53 insertions(+), 58 deletions(-) diff --git a/app/src/main/java/com/application/zhangshi_app_android/adapter/GrowthExperiencePrimaryRvAdapter.java b/app/src/main/java/com/application/zhangshi_app_android/adapter/GrowthExperiencePrimaryRvAdapter.java index b68e60b..e543947 100644 --- a/app/src/main/java/com/application/zhangshi_app_android/adapter/GrowthExperiencePrimaryRvAdapter.java +++ b/app/src/main/java/com/application/zhangshi_app_android/adapter/GrowthExperiencePrimaryRvAdapter.java @@ -2,6 +2,7 @@ import android.content.Context; import android.content.Intent; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -14,14 +15,18 @@ import com.android.app_base.base.adapter.BaseRVAdapter; import com.android.app_base.manager.AppManager; +import com.android.app_base.utils.Utils; import com.application.zhangshi_app_android.R; import com.application.zhangshi_app_android.bean.GrowthExperienceBean; +import com.application.zhangshi_app_android.bean.TourismBean; import com.application.zhangshi_app_android.databinding.ItemGrowthExperiencePrimaryBinding; import com.application.zhangshi_app_android.ui.function.GrowthExperienceActivity; import com.application.zhangshi_app_android.ui.function.GrowthExperienceActivityViewModel; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @author Gss @@ -29,20 +34,10 @@ * @desc 鎴愰暱缁忓巻(涓昏瀛︿範鍙婂伐浣滅粡鍘�) recyclerView 鐨� adapter */ public class GrowthExperiencePrimaryRvAdapter extends BaseRVAdapter<GrowthExperienceBean, ItemGrowthExperiencePrimaryBinding, GrowthExperiencePrimaryRvAdapter.ViewHolder> { - - private GrowthExperienceActivityViewModel viewModel; + private final Map<GrowthExperienceBean, Boolean> expendMap = new HashMap<>(); public GrowthExperiencePrimaryRvAdapter(Context context) { super(context); - } - - public GrowthExperiencePrimaryRvAdapter(Context context, GrowthExperienceActivityViewModel viewModel) { - super(context); - this.viewModel = viewModel; - } - - public GrowthExperiencePrimaryRvAdapter(GrowthExperienceActivity growthExperienceActivity) { - super(growthExperienceActivity); } @Override @@ -51,7 +46,7 @@ } @Override - protected ViewHolder getViewHolder(ItemGrowthExperiencePrimaryBinding itemBind) { + protected ViewHolder getViewHolder(ItemGrowthExperiencePrimaryBinding itemBind,int viewType) { return new ViewHolder(itemBind); } @@ -60,59 +55,59 @@ holder.getBinding().setBean(mDataList.get(position)); + //鏍规嵁涓婚閫夋嫨瀵瑰簲鍗$墖鑳屾櫙鑹� + TypedValue typedValue1 = new TypedValue(); + mContext.getTheme().resolveAttribute(R.attr.cardBackgroundColorFirst, typedValue1, true); + TypedValue typedValue2 = new TypedValue(); + mContext.getTheme().resolveAttribute(R.attr.cardBackgroundColorSecond, typedValue2, true); if (position % 2 != 0){ - holder.getBinding().cardView.setCardBackgroundColor(mContext.getColor(R.color.color_card_blue)); + holder.getBinding().cardView.setCardBackgroundColor(typedValue1.data); }else { - holder.getBinding().cardView.setCardBackgroundColor(mContext.getColor(R.color.color_card_pink)); + holder.getBinding().cardView.setCardBackgroundColor(typedValue2.data); + } + if (!expendMap.containsKey(getItem(position))){ + expendMap.put(getItem(position),false); + } + //鏍规嵁涓婚閫夋嫨瀵瑰簲鍥炬爣 + TypedValue unfoldIcon = new TypedValue(); + mContext.getTheme().resolveAttribute(R.attr.icUnfold, unfoldIcon, true); + TypedValue foldIcon = new TypedValue(); + mContext.getTheme().resolveAttribute(R.attr.icFold, foldIcon, true); + if (Boolean.TRUE.equals(expendMap.get(getItem(position)))){ + holder.getBinding().ivFold.setBackgroundResource(unfoldIcon.resourceId); + holder.getBinding().cardView.post(() -> { + holder.getBinding().cardView.getLayoutParams().height = FrameLayout.LayoutParams.WRAP_CONTENT; + holder.getBinding().cardView.requestLayout(); + }); + }else{ + holder.getBinding().ivFold.setBackgroundResource(foldIcon.resourceId); + holder.getBinding().cardView.post(() -> { + holder.getBinding().cardView.getLayoutParams().height = holder.getBinding().layoutTitle.getMeasuredHeight(); + holder.getBinding().cardView.requestLayout(); + }); } holder.getBinding().layoutTitle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if (holder.isExpended){ - int initialHeight = holder.getBinding().cardView.getMeasuredHeight(); - int collapsedHeight = holder.getBinding().layoutTitle.getMeasuredHeight(); - int distanceToCollapse = (int) (initialHeight - collapsedHeight); - - Animation a = new Animation() { - @Override - protected void applyTransformation(float interpolatedTime, Transformation t) { - if (interpolatedTime == 1){ - } - holder.getBinding().cardView.getLayoutParams().height = (int) (initialHeight - (distanceToCollapse * interpolatedTime)); - holder.getBinding().cardView.requestLayout(); + holder.getBinding().layoutTitle.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (Boolean.TRUE.equals(expendMap.get(getItem(position)))){ + int initialHeight = holder.getBinding().cardView.getMeasuredHeight(); + int collapsedHeight = holder.getBinding().layoutTitle.getMeasuredHeight(); + Utils.pullCollapse(holder.getBinding().cardView,initialHeight,collapsedHeight); + expendMap.put(getItem(position),false); + holder.getBinding().ivFold.setBackgroundResource(foldIcon.resourceId); + }else{ + final int initialHeight = holder.getBinding().cardView.getMeasuredHeight(); + holder.getBinding().cardView.measure(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); + int targetHeight = holder.getBinding().cardView.getMeasuredHeight(); + Utils.dropExpand(holder.getBinding().cardView,initialHeight,targetHeight); + expendMap.put(getItem(position),true); + holder.getBinding().ivFold.setBackgroundResource(unfoldIcon.resourceId); } - - @Override - public boolean willChangeBounds() { - return true; - } - }; - a.setDuration(500); - holder.getBinding().cardView.startAnimation(a); - holder.isExpended = false; - }else{ - final int initialHeight = holder.getBinding().cardView.getMeasuredHeight(); - holder.getBinding().cardView.measure(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); - int targetHeight = holder.getBinding().cardView.getMeasuredHeight(); - int distanceToExpand = targetHeight - initialHeight; - Animation a = new Animation() { - @Override - protected void applyTransformation(float interpolatedTime, Transformation t) { - if (interpolatedTime == 1){ - } - holder.getBinding().cardView.getLayoutParams().height = (int) (initialHeight + (distanceToExpand * interpolatedTime)); - holder.getBinding().cardView.requestLayout(); - } - - @Override - public boolean willChangeBounds() { - return true; - } - }; - a.setDuration(500); - holder.getBinding().cardView.startAnimation(a); - holder.isExpended = true; - } + } + }); } }); -- Gitblit v1.9.1