private void setFamilyMember(String familyMember) { List<FamilyMember> mfamilyMemberList = new ArrayList<FamilyMember>(); try { mfamilyMemberList = new JsonUtil().jsonToObjects(familyMember, FamilyMember.class); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } int num = mfamilyMemberList.size(); familyMemberList.removeAll(familyMemberList); for (int i = 0; i < num; i++) { familyMemberList.add(mfamilyMemberList.get(i)); } familyMemberAdapter.notifyDataSetChanged(); }
@Override public void refreshData() { if (familyMermberButton == null) { return; } ArchiveInfo archiveInfo = MyApplication.getInstance().getArchiveInfo(); if (archiveInfo != null) { String familyMember = archiveInfo.getFamilyMermber(); // Log.i("cjl", familyMember); if (TextUtils.isEmpty(familyMember) || "[]".equals(familyMember)) { familyMemberList.removeAll(familyMemberList); familyMemberAdapter.notifyDataSetChanged(); } else { setFamilyMember(familyMember); } } }
@Override public void onClick(View item, View widget, final int position, int which) { // TODO Auto-generated method stub final FamilyMember myFamilyMember; myFamilyMember = familyMemberList.get(position); switch (which) { case R.id.edit_btn: final FamilyMemberDialog familyMemberDialog = new FamilyMemberDialog( true, myFamilyMember.getName(), myFamilyMember.getGender(), myFamilyMember.getBirthday(), myFamilyMember.getRelationship(), myFamilyMember.getEducation(), myFamilyMember.getJob(), myFamilyMember.getIdcard(), myFamilyMember.getMarriage(), myFamilyMember.getPersonalStatus(), myFamilyMember.getRemark()); familyMemberDialog.show(getChildFragmentManager(), "familyMemberDialog"); familyMemberDialog.setOnFamilyMemberDialog( new OnFamilyMemberDialog() { @Override public void onConfirmClick(FamilyMember familyMember) { if (familyMember != null) { if (!familyMember.toString().equals(myFamilyMember.toString())) { familyMemberList.set(position, familyMember); familyMemberAdapter.notifyDataSetChanged(); familyMemberDialog.hide(); } } } }); break; case R.id.delete_btn: familyMemberList.remove(position); familyMemberAdapter.notifyDataSetChanged(); break; case R.id.detail_btn: final FamilyMemberDialog familyMemberDialog2 = new FamilyMemberDialog( false, myFamilyMember.getName(), myFamilyMember.getGender(), myFamilyMember.getBirthday(), myFamilyMember.getRelationship(), myFamilyMember.getEducation(), myFamilyMember.getJob(), myFamilyMember.getIdcard(), myFamilyMember.getMarriage(), myFamilyMember.getPersonalStatus(), myFamilyMember.getRemark()); familyMemberDialog2.show(getChildFragmentManager(), "familyMemberDialog"); familyMemberDialog2.setOnFamilyMemberDialog( new OnFamilyMemberDialog() { @Override public void onConfirmClick(FamilyMember familyMember) { familyMemberDialog2.hide(); } }); break; default: break; } }