| | |
| | | package com.application.zhangshi_app_android.adapter; |
| | | |
| | | import android.content.Context; |
| | | import android.util.TypedValue; |
| | | import android.view.View; |
| | | import android.view.animation.Animation; |
| | | import android.view.animation.Transformation; |
| | |
| | | ContactsDetailAdapter adapter = new ContactsDetailAdapter(mContext); |
| | | holder.getBinding().recyclerView.setAdapter(adapter); |
| | | adapter.setData(mDataList.get(position).getContactsDetailBeans()); |
| | | //根据主题选择对应卡片背景色 |
| | | 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(R.drawable.ic_unfold); |
| | | 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(R.drawable.ic_fold); |
| | | holder.getBinding().ivFold.setBackgroundResource(foldIcon.resourceId); |
| | | holder.getBinding().cardView.post(() -> { |
| | | holder.getBinding().cardView.getLayoutParams().height = holder.getBinding().layoutTitle.getMeasuredHeight(); |
| | | holder.getBinding().cardView.requestLayout(); |