From e6014ef123350d5c0cadabe9c18e26b3d5a3c729 Mon Sep 17 00:00:00 2001
From: guoshen <3129367635@qq.com>
Date: 星期六, 29 六月 2024 15:41:25 +0800
Subject: [PATCH] Revert "Initial commit"
---
app/src/main/java/com/application/zhangshi_app_android/adapter/PropertyRvAdapter.java | 101 +++++++++++++++++++++++---------------------------
1 files changed, 46 insertions(+), 55 deletions(-)
diff --git a/app/src/main/java/com/application/zhangshi_app_android/adapter/PropertyRvAdapter.java b/app/src/main/java/com/application/zhangshi_app_android/adapter/PropertyRvAdapter.java
index 38c457d..c88c967 100644
--- a/app/src/main/java/com/application/zhangshi_app_android/adapter/PropertyRvAdapter.java
+++ b/app/src/main/java/com/application/zhangshi_app_android/adapter/PropertyRvAdapter.java
@@ -2,6 +2,7 @@
import android.content.Context;
import android.content.Intent;
+import android.util.TypedValue;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
@@ -11,16 +12,21 @@
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.PropertyBean;
+import com.application.zhangshi_app_android.bean.TourismBean;
import com.application.zhangshi_app_android.databinding.ItemCleanStorageBinding;
import com.application.zhangshi_app_android.databinding.ItemPropertyBinding;
import com.application.zhangshi_app_android.ui.function.CleanStorageDetailActivity;
+import com.application.zhangshi_app_android.ui.function.FamilyAssetsDetailActivity;
import com.application.zhangshi_app_android.ui.function.PropertyDetailActivity;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* @author Ljj
@@ -28,6 +34,8 @@
* @desc 涓汉璐骇 Adapter
*/
public class PropertyRvAdapter extends BaseRVAdapter<PropertyBean, ItemPropertyBinding, PropertyRvAdapter.ViewHolder> {
+ private final Map<PropertyBean, Boolean> expendMap = new HashMap<>();
+
public PropertyRvAdapter(Context context) {
super(context);
}
@@ -45,58 +53,53 @@
@Override
protected void onBind(ViewHolder holder, int position) {
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){
+ if (Boolean.TRUE.equals(expendMap.get(getItem(position)))){
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();
- }
-
- @Override
- public boolean willChangeBounds() {
- return true;
- }
- };
- a.setDuration(500);
- holder.getBinding().cardView.startAnimation(a);
- holder.isExpended = false;
+ Utils.pullCollapse(holder.getBinding().cardView,initialHeight,collapsedHeight);
+ holder.getBinding().ivFold.setBackgroundResource(foldIcon.resourceId);
+ expendMap.put(getItem(position),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;
+ Utils.dropExpand(holder.getBinding().cardView,initialHeight,targetHeight);
+ holder.getBinding().ivFold.setBackgroundResource(unfoldIcon.resourceId);
+ expendMap.put(getItem(position),true);
}
}
});
@@ -105,23 +108,11 @@
new Intent(getRecyclerView().getContext(), PropertyDetailActivity.class)
.putExtra("bean",mDataList.get(position)));
});
-
- ImageRvAdapter adapter = new ImageRvAdapter(mContext);
+ ElectronicFileAdapter adapter = new ElectronicFileAdapter(mContext);
holder.getBinding().rvImage.setLayoutManager(new GridLayoutManager(mContext,3));
holder.getBinding().rvImage.setAdapter(adapter);
- String url = mDataList.get(position).getUrl();
- if (url == null||url.isEmpty()){
- return;
- }
- List<String> list;
- if (url.contains(",")){
- String[] split = url.split(",");
- list = new ArrayList<>(Arrays.asList(split));
- }else {
- list = new ArrayList<>();
- list.add(url);
- }
- adapter.setData(list);
+ adapter.setData(Utils.splitString2List(mDataList.get(position).getUrl(),","));
+
}
public static class ViewHolder extends BaseRVAdapter.BaseViewHolder<ItemPropertyBinding> {
--
Gitblit v1.9.1