static class MyAdapter extends CommonAdapter {
public MyAdapter() {
super(R.layout.item_my_sign, null);
}
@Override
protected void convert(final ViewHolder holder, final PatientVo item, final int position) {
SimpleDraweeView dvHeader = holder.getView(R.id.dvHeader);
TextView tvName = holder.getView(R.id.tvName);
TextView tvAge = holder.getView(R.id.tvAge);
TextView tvState = holder.getView(R.id.tvState);
TextView tvAddress = holder.getView(R.id.tvAddress);
TextView tvFlag = holder.getView(R.id.tvFlag);
TextView tvTeam = holder.getView(R.id.tvTeam);
TextView tvTime = holder.getView(R.id.tvTime);
TextView tvDeputy = holder.getView(R.id.tv_deputy);
TextView tvFamilyNum = holder.getView(R.id.tv_family_num);
ImageView ivGender = holder.getView(R.id.ivGender);
ImageUtil.showNetWorkImage(dvHeader,
ImageSizeUtil.getHeaderUrl(
ImageUrlUtil.getUrl(Constants.HttpImgUrl, item.personHeader),
dvHeader.getLayoutParams().width), R.drawable.avatar_none);
ivGender.setImageResource(item.getGenderRes2());
tvName.setText(StringUtil.notNull(item.personName));
tvAge.setText(item.getAge());
tvAddress.setText(item.getAddress());
tvTeam.setText(StringUtil.notNull(item.teamName));
tvTime.setText(item.getOptTimeStr());
int[] color = new int[4];
String[] txt = new String[2];
item.buildState(color, txt);
tvState.setTextColor(ContextCompat.getColor(holder.getContext(), color[0]));
tvState.setBackgroundResource(color[1]);
tvState.setText(txt[0]);
tvFlag.setText(txt[1]);
tvFlag.setTextColor(ContextCompat.getColor(holder.getContext(), color[3]));
tvFlag.setBackgroundResource(color[2]);
EffectUtil.addClickEffect(holder.getConvertView());
if ("2".equals(item.signModelType)) { //家庭签约
tvDeputy.setVisibility(View.VISIBLE);
tvName.setText(StringUtil.isEmpty(item.familyRepresentPersonName) ? item.personName : item.familyRepresentPersonName);
} else {
tvDeputy.setVisibility(View.GONE);
}
if (item.familyTerminateSignCount > 0) {
tvFamilyNum.setText(item.familyTerminateSignCount + "人解约");
tvFamilyNum.setVisibility(View.VISIBLE);
} else {
tvFamilyNum.setVisibility(View.GONE);
}
}
}
=========================================================
public class PatientVo extends BaseVo {
/**
* signId : 1
* personHeader : 11
* personName : 张三
* address : 中山小唐山
* teamName : 测试
* teamLeaderName : 生产
* signState : 13
* age : 12
*/
/**
* 省id,330000
*/
public String province = "";
/**
* 市id,330100
*/
public String city = "";
/**
* 区(县)id,330101
*/
public String district = "";
/**
* 街道id,330101001
*/
public String street = "";
/**
* 地址
*/
public String provinceText = "";
public String cityText = "";
public String districtText = "";
public String streetText = "";
public String signId;
public String familySignGroupNo;
public String personHeader;
public String personName;
public String address;
public String teamName;
public String teamLeaderName;
public int age = -1;
public String ageStr;
public String signState;
public String sex;
public String signStateText;
public Long createAt;
public Long operateTime;
public String signModelType;
public int familyTerminateSignCount;//解约数
public String familyRepresentPersonName;
public Long endDate;//签约周期结束时间
public int residentCount;//家庭成员人数
public boolean isFamilyMode() {
return signModelType != null && "2".equals(signModelType);
}
public String getAddress() {
StringBuffer sb = new StringBuffer();
sb.append(provinceText).append(cityText).append(districtText)
.append(streetText).append(address);
return sb.toString();
}
public CharSequence getCreateTimeStr() {
return createAt == null ? "" : DateUtil.getDateTime("yyyy-MM-dd HH:mm", createAt);
}
public CharSequence getOptTimeStr() {
return operateTime == null ? "" : DateUtil.getDateTime("yyyy-MM-dd HH:mm", operateTime);
}
public String getAge() {
if (!StringUtil.isEmpty(ageStr)) {
return ageStr;
}
return age + "岁";
}
/**
* 获取到期时间
*
* @return
*/
public String getEndTime() {
if (endDate == null) {
return null;
}
Calendar calendar = Calendar.getInstance();
int curYear = calendar.get(Calendar.YEAR);
int curDay = calendar.get(Calendar.DAY_OF_YEAR);
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTimeInMillis(endDate);
int endYear = endCalendar.get(Calendar.YEAR);
int endDay = endCalendar.get(Calendar.DAY_OF_YEAR);
if (curYear == endYear) {
if (curDay == endDay) {
return "今天";
} else if (endDay - curDay == 1) {
return "明天";
}
}
return DateUtil.getDateTime("yyyy-MM-dd", endDate);
}
/**
* 签约申请
*
* @return
*/
public boolean isSignApply() {
return SignDocStateUtil.isSignApply(signState);
}
/**
* 签约待确认
*
* @return
*/
public boolean isSignWait() {
return SignDocStateUtil.isSignWait(signState);
}
/**
* 签约已确认
*
* @return
*/
public boolean isSignConfirmed() {
return SignDocStateUtil.isSignConfirmed(signState);
}
/**
* 改签申请
*
* @return
*/
public boolean isChangeApply() {
return SignDocStateUtil.isChangeApply(signState);
}
/**
* 改签待确认
*
* @return
*/
public boolean isChangeWait() {
return SignDocStateUtil.isChangeWait(signState);
}
/**
* 改签已确认
*
* @return
*/
public boolean isChangeConfirmed() {
return SignDocStateUtil.isChangeConfirmed(signState);
}
/**
* 解签申请
*
* @return
*/
public boolean isUnsignApply() {
return SignDocStateUtil.isUnsignApply(signState);
}
/**
* 解签申请-待确认
*
* @return
*/
public boolean isUnsignWait() {
return SignDocStateUtil.isUnsignWait(signState);
}
/**
* 11 签约申请-待确认
* 12 签约申请-已取消
* 13 签约申请-已确认
* 14 签约申请-未通过
* 21 改签申请-待确认
* 22 改签申请-已确认
* 23 改签申请-未通过
* 31 解签申请-待确认
* 32 解签申请-已确认
* 33 解签申请-未通过
* 90 已过期
*/
public void buildState(int[] color, String[] txt) {
if (TextUtils.isEmpty(signState)) return;
color[3] = R.color.orange;
if (isSignApply()) {
txt[1] = "签约";
color[2] = R.drawable.orange_white_corners;
color[3] = R.color.orange;
} else if (isUnsignApply()) {
txt[1] = "解约";
color[2] = R.drawable.cyan_white_corners;
color[3] = R.color.darkturquoise;
} else if (isChangeApply()) {
txt[1] = "改签";
color[2] = R.drawable.cyan_white_corners;
color[3] = R.color.darkturquoise;
}
switch (signState) {
case SignDocStateUtil.SIGN_WAIT:
case SignDocStateUtil.CHANGE_WAIT:
color[0] = R.color.orange;
color[1] = R.drawable.orange_white_corners;
txt[0] = "签约审核";
break;
case SignDocStateUtil.UNSIGN_WAIT:
color[0] = R.color.darkturquoise;
color[1] = R.drawable.cyan_white_corners;
txt[0] = "解约审核";
break;
case SignDocStateUtil.SIGN_CANCEL:
case SignDocStateUtil.UNSIGN_CONFIRMED:
color[0] = R.color.orange;
color[1] = R.drawable.transparent;
txt[0] = "已取消";
break;
case SignDocStateUtil.SIGN_CONFIRMED:
case SignDocStateUtil.CHANGE_CONFIRMED:
color[0] = R.color.orange;
color[1] = R.drawable.transparent;
txt[0] = "已签约";
break;
case SignDocStateUtil.SIGN_REFUSE:
case SignDocStateUtil.UNSIGN_NOTPASS:
case SignDocStateUtil.CHANGE_REFUSE:
color[0] = R.color.orange;
color[1] = R.drawable.transparent;
txt[0] = "未通过";
break;
case SignDocStateUtil.UNSIGN_REFUSE:
color[0] = R.color.orange;
color[1] = R.drawable.transparent;
txt[0] = "已解约";
break;
case SignDocStateUtil.OUT_DATE:
color[0] = R.color.orange;
color[1] = R.drawable.transparent;
txt[0] = "已过期";
break;
default:
color[0] = R.color.orange;
color[1] = R.color.transparent;
}
}
public boolean isOutAge() {
if ((age >= 0 && age <= 6) || age >= 65) {
return false;
}
return true;
}
public boolean isBaby() {
if (age >= 0 && age <= 6) {
return true;
}
return false;
}
public boolean isOlder() {
if (age >= 65) {
return true;
}
return false;
}
public int getGenderRes() {
if (TextUtils.equals("1", sex)) {
return R.drawable.male_1;
} else if (TextUtils.equals("2", sex)) {
return R.drawable.female_1;
}
return 0;
}
public int getGenderRes2() {
if (TextUtils.equals("1", sex)) {
return R.drawable.male;
} else if (TextUtils.equals("2", sex)) {
return R.drawable.female;
}
return 0;
}
public String getSexValue() {
if (TextUtils.equals("1", sex)) {
return "男";
} else if (TextUtils.equals("2", sex)) {
return "女";
}
return "";
}
}
================================================
private void addPackageView(LinearLineWrapLayout lay, List packageVos) { lay.removeAllViews();
if (packageVos != null)
for (final ServicePackageVo vo : packageVos) {
TextView view = (TextView) LayoutInflater.from(baseContext).inflate(
R.layout.item_service_package_simple, null);
LinearLineWrapLayout.LayoutParams layoutParams = new LinearLineWrapLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(getResources().getDimensionPixelSize(R.dimen.dp15),
getResources().getDimensionPixelSize(R.dimen.dp5),
getResources().getDimensionPixelSize(R.dimen.dp0),
getResources().getDimensionPixelSize(R.dimen.dp5));
view.setLayoutParams(layoutParams);
view.setText(vo.spPackName);
EffectUtil.addClickEffect(view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(baseContext, PackageDetailActivity.class);
intent.putExtra("packageVo", vo);
startActivity(intent);
}
});
lay.addView(view);
}
}
============================
static class ResiderntLabelAdapter extends CommonAdapter<ResidentLabelAllVo> {
public ResiderntLabelAdapter() {
super(R.layout.item_resident_label_save);
}
@Override
protected void convert(ViewHolder holder, final ResidentLabelAllVo item, int position) {
RelativeLayout rl_label = holder.getView(R.id.rl_label);
TextView tv_label = holder.getView(R.id.tv_label);
final ImageView iv_arrow = holder.getView(R.id.iv_arrow);
final LinearLineWrapLayout layLabel = holder.getView(R.id.layLabel);
tv_label.setText(item.teamName + "人群");
layLabel.removeAllViews();
arrowAnim(true, iv_arrow);
if (item.state) {
layLabel.setVisibility(View.VISIBLE);
} else {
layLabel.setVisibility(View.GONE);
}
for (int i = 0; i < item.signPersonGroupBean.size(); i++) {
layLabel.addView(createLabel(holder, item, position, i));
}
rl_label.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
item.state = !item.state;
if (item.state) {
layLabel.setVisibility(View.VISIBLE);
arrowAnim(true, iv_arrow);
} else {
layLabel.setVisibility(View.GONE);
arrowAnim(false, iv_arrow);
}
}
});
}
public void arrowAnim(final boolean show, View imageView) {
if (show) {
ObjectAnimator anim = ObjectAnimator.ofFloat(imageView, "rotation", 0, 180);
anim.start();
} else {
ObjectAnimator.ofFloat(imageView, "rotation", 180, 0).start();
}
}
private View createLabel(final ViewHolder holder, final ResidentLabelAllVo item, final int position, final int tPos) {
LinearLayout view = (LinearLayout) View.inflate(holder.getContext(),
R.layout.item_resident_label, null);
LinearLineWrapLayout.LayoutParams layoutParams = new LinearLineWrapLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
LinearLineWrapLayout.LayoutParams.WRAP_CONTENT);
TextView tv_label = (TextView) view.findViewById(R.id.tv_label);
ImageView iv_state = (ImageView) view.findViewById(R.id.iv_state);
ResidentLabelVo residentLabelVo = item.signPersonGroupBean.get(tPos);
tv_label.setText(residentLabelVo.groupName);
if (residentLabelVo.state >= ResidentLabelVo.CANT_SELECTED) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
tv_label.setTextColor(holder.getContext().getColor(R.color.gray_text));
} else {
tv_label.setTextColor(holder.getContext().getResources().getColor(R.color.gray_text));
}
view.setClickable(false);
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
tv_label.setTextColor(holder.getContext().getColor(R.color.black_text));
} else {
tv_label.setTextColor(holder.getContext().getResources().getColor(R.color.black_text));
}
view.setClickable(true);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemViewClick(v, holder, item, position, tPos);
}
}
});
}
iv_state.setBackgroundResource(residentLabelVo.state == ResidentLabelVo.SELECTED ? R.drawable.btn_checked_n
: R.drawable.btn_checked_p);
view.setLayoutParams(layoutParams);
return view;
}
}