@Override public View getChildView( int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.child_light_all, parent, false); } LightingBean child = getChild(groupPosition, childPosition); convertView.setOnClickListener( v -> { Intent intent = new Intent(mContext, CreateLightingActivity.class); intent.putExtra("mode", 1); intent.putExtra("bean", child); mContext.startActivity(intent); }); TextView tvTitle = (TextView) convertView.findViewById(R.id.all_child_content); tvTitle.setText(child.title); TextView tvTime = (TextView) convertView.findViewById(R.id.all_child_time); if (child.reminderTime == 0) { tvTime.setVisibility(View.GONE); } else { tvTime.setVisibility(View.VISIBLE); tvTime.setText(String.valueOf(child.reminderTime)); } View document = convertView.findViewById(R.id.all_to_document); ImageView ivCheckBox = (ImageView) convertView.findViewById(R.id.all_cb); if (child.status == 0) { ivCheckBox.setImageResource(R.mipmap.icon_checkbox_nor); tvTitle.getPaint().setFlags(0); tvTitle.setTextColor(mContext.getResources().getColor(android.R.color.black)); document.setVisibility(View.INVISIBLE); } else { ivCheckBox.setImageResource(R.mipmap.icon_checkbox_pres); tvTitle.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG); tvTitle.setTextColor(mContext.getResources().getColor(R.color.lighting_inactive_color)); document.setVisibility(View.VISIBLE); } ivCheckBox.setOnClickListener( v -> { if (child.status == 0) { ivCheckBox.setImageResource(R.mipmap.icon_checkbox_pres); child.status = 1; } else { ivCheckBox.setImageResource(R.mipmap.icon_checkbox_nor); child.status = 0; } DBManager.getInstance(mContext).updateHintStatus(child.id, child.status); notifyDataSetChanged(); }); return convertView; }
private Map<String, List<LightingBean>> loadLightingBeanMap() { Map<String, List<LightingBean>> lightingBeanMap = new HashMap<>(); String[] group = mContext.getResources().getStringArray(R.array.lighting_main_group); for (int i = 0; i < group.length; i++) { String s = group[i]; if (i == 0) { lightingBeanMap.put(s, DBManager.getInstance(mContext).getHintList()); } else { lightingBeanMap.put(s, new ArrayList<>()); } } return lightingBeanMap; }