@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_contact_detail, container, false); view.findViewById(R.id.btn_send_message).setOnClickListener(this); mDetailHelper.setParentView(view); mDetailHelper.bindInfo(); mDetailHelper.bindLabels(); return view; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Activity activity = getActivity(); mContactsManager = ContactsManager.getInstance(activity); mContactsManager.registerListener(mContactListener); mLabelManager = UserLabelManager.getInstance(activity); loadContact(); mDetailHelper = new UserDetailHelper(activity, mHelperListener); if (mContact != null) { mDetailHelper.setDetail(new UserDetailHelper.Detail(mContact)); mLabelIdMap = buildLabelIdMap(mContact.getLabels()); } mMyLabelIdList = buildLabelIdList(mLabelManager.getAllLabels()); setHasOptionsMenu(true); final ActionBar actionBar = activity.getActionBar(); if (actionBar != null) { if (mContact != null) { actionBar.setTitle(mContact.getShowName()); } else { actionBar.setTitle(R.string.friend_detail); } } mContactQueried = false; mLabelPraiseLoaded = false; if (mContact != null) { queryContactInfo(); loadLabelPraise(); } }
private void updateContactLabelPraise() { if (!mContactQueried || !mLabelPraiseLoaded) { return; } if (mLabelPraises != null && mLabelPraises.length > 0) { final String userId = mContact.getUserId(); for (LabelPraise labelPraise : mLabelPraises) { UserLabel userLabel = mLabelIdMap.get(labelPraise.getLabelId()); if (userLabel != null && userId.equals(labelPraise.getUserId())) { userLabel.setPraiseCount(labelPraise.getPraiseCount()); } } } // update list view and contact mDetailHelper.setDetail(new UserDetailHelper.Detail(mContact)); mDetailHelper.bindInfo(); mDetailHelper.bindLabels(); mContactsManager.updateContact(mContact); }