コード例 #1
0
  @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();
    }
  }
コード例 #2
0
  private void handleModifyRemarkResult(Object object) {
    if (!(object instanceof ModifyResult)) {
      return;
    }

    final ModifyResult result = (ModifyResult) object;

    if (!mContact.getUserId().equals(result.mFriendUserId)
        || !mNewRemark.equals(result.mFriendRemark)) {
      return;
    }

    if (mInModifyRemark) {
      final Activity activity = getActivity();

      if (result.mResult == ConstantCode.CONTACT_OPERATION_SUCCESS) {
        Toast.makeText(activity, R.string.modify_remark_success, Toast.LENGTH_SHORT).show();
        mContact.setRemarkName(mNewRemark);
        final ActionBar actionBar = getActivity().getActionBar();
        if (actionBar != null) {
          actionBar.setTitle(mContact.getShowName());
        }
      } else {
        Toast.makeText(activity, R.string.modify_remark_failure, Toast.LENGTH_SHORT).show();
      }
      mInModifyRemark = false;
      dismissProgressDialog();
    }
  }
コード例 #3
0
 public AlbumItem(Context context, UserContact userContact) {
   mContext = context;
   if (userContact != null) {
     photoTotal = userContact.getMyPhotoTotal();
     mUserContact = userContact;
     mAlbumPhotos = userContact.getAlbumPhotos();
   }
   mAlbumManager = AlbumManager.getInstance(mContext);
 }
コード例 #4
0
 private void handleQueryContactInfoResult(int result, UserContact contact) {
   L.v(TAG, "handleQueryContactInfoResult(), result=%1$d, count=%2$s", result, contact);
   if (contact != null && contact.getUserId().equals(mContact.getUserId())) {
     contact.setId(mContact.getId());
     mContact = contact;
     mLabelIdMap = buildLabelIdMap(mContact.getLabels());
   }
   mContactQueried = true;
   updateContactLabelPraise();
 }
コード例 #5
0
 public DynamicItem(Activity activity, UserContact userContact, boolean lastItem) {
   mActivity = activity;
   if (userContact != null) {
     mUserContact = userContact;
     mLabelStory = userContact.getLabelStories();
   }
   this.lastItem = lastItem;
 }
コード例 #6
0
 public PersonLabelItem(
     Context context, UserContact userContact, InteractListener interactListener) {
   mContext = context;
   if (userContact != null) {
     mUserTag = userContact.getUserTags();
   }
   this.interactListener = interactListener;
 }
コード例 #7
0
 public FavoriteInterestItem(
     Context context, UserContact userContact, InteractListener interactListener) {
   mContext = context;
   if (userContact != null) {
     mInterestTypes = userContact.getInterestTypes();
   }
   this.interactListener = interactListener;
 }
コード例 #8
0
 private void modifyRemark(String newRemark) {
   if (!mInModifyRemark) {
     newRemark = (newRemark == null) ? "" : newRemark;
     mInModifyRemark = true;
     showProgressDialog();
     mNewRemark = newRemark;
     mContactsManager.modifyFriendRemark(mContact.getUserId(), newRemark);
   }
 }
コード例 #9
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.btn_send_message:
       UILauncher.launchChattingUI(getActivity(), mContact.getUserId());
       finish();
       break;
     default:
       break;
   }
 }
コード例 #10
0
 private void queryContactInfo() {
   mContactsManager.queryContactInfo(
       mContact.getUserId(),
       new ContactsManager.ContactQueryObserver() {
         @Override
         public void onQueryResult(int result, UserContact contact) {
           Message msg = mHandler.obtainMessage(MSG_QUERY_CONTACT_INFO_RESULT, result, 0, contact);
           mHandler.sendMessage(msg);
         }
       });
 }
コード例 #11
0
 private void loadLabelPraise() {
   mLabelManager.queryLabelPraise(
       mContact.getUserId(),
       new UserLabelManager.LabelPraiseQueryObserver() {
         @Override
         public void onQueryResult(int result, LabelPraise[] labelPraises) {
           Message msg =
               mHandler.obtainMessage(MSG_LOAD_LABEL_PRAISE_RESULT, result, 0, labelPraises);
           mHandler.sendMessage(msg);
         }
       });
 }
コード例 #12
0
  private void loadContact() {
    final Bundle args = getArguments();
    final Activity activity = getActivity();
    UserContact contact = null;

    if (args != null) {
      contact = mContactsManager.getUserContactByUserId(args.getString(EXTRA_FRIEND_USER_ID));
    }

    if (contact == null) {
      Toast.makeText(activity, R.string.empty_contact, Toast.LENGTH_SHORT).show();
      finish();
    }

    final ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null && contact != null) {
      actionBar.setTitle(contact.getShowName());
    }

    mContact = contact;
  }
コード例 #13
0
 private void recommendLabel(BaseLabel[] labels) {
   mProgressHelper.show();
   mLabelManager.recommendLabel(
       mContact.getUserId(),
       labels,
       new FunctionCallListener() {
         @Override
         public void onCallResult(int result, int errorCode, String errorDesc) {
           mHandler.sendMessage(
               mHandler.obtainMessage(MSG_RECOMMEND_LABEL_RESULT, result, errorCode));
         }
       });
 }
コード例 #14
0
  private void showRemarkEditDialog() {
    SimpleEditDialog.UiConfig config = new SimpleEditDialog.UiConfig();
    config.title = getString(R.string.modify_remark);
    config.initText = mContact.getRemarkName();
    config.editHint = getString(R.string.friend_remark_hint);
    config.maxLength = getResources().getInteger(R.integer.friend_remark_max_length);
    config.listener =
        new SimpleEditDialog.IListener() {
          @Override
          public void onCancel(CharSequence text) {}

          @Override
          public void onOK(CharSequence text) {
            modifyRemark(text.toString());
          }
        };
    SimpleEditDialog.newInstance(config).show(getFragmentManager(), "RemarkEditDialog");
  }
コード例 #15
0
  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);
  }
コード例 #16
0
 private void startDeleteFriend() {
   showProgressDialog();
   mContactsManager.deleteFriend(mContact.getUserId(), mContact.getLabelCode());
 }
コード例 #17
0
    @Override
    public void bindView(View view) {
      ViewHolder holder = (ViewHolder) view.getTag();
      LayoutInflater inflater = LayoutInflater.from(context);
      Resources res = context.getResources();

      holder.infoContainer.removeAllViews();
      addNewInfoItem(
          contact.getNickname(),
          ConstantCode.getSexImageResource(contact.getSex()),
          inflater,
          holder.infoContainer);
      addNewInfoItem(
          context.getString(R.string.label_code) + contact.getLabelCode(),
          inflater,
          holder.infoContainer);
      if (contact.getAge() > 0) {
        addNewInfoItem(
            MiscUtils.getAgeString(res, contact.getAge()), inflater, holder.infoContainer);
      }
      if (contact.getHeight() > 0) {
        addNewInfoItem(
            MiscUtils.getHeightString(res, contact.getHeight()), inflater, holder.infoContainer);
      }
      if (contact.getConstellation() > 0) {
        addNewInfoItem(
            MiscUtils.getConstellationString(res, contact.getConstellation()),
            inflater,
            holder.infoContainer);
      }
      if (!TextUtils.isEmpty(contact.getSchool())) {
        addNewInfoItem(contact.getSchool(), inflater, holder.infoContainer);
      }
      if (!TextUtils.isEmpty(contact.getJob())) {
        addNewInfoItem(contact.getJob(), inflater, holder.infoContainer);
      }
    }
コード例 #18
0
 private void handleContactDefriendedMe(String friendUserId) {
   if (mContact != null && mContact.getUserId().equals(friendUserId)) {
     finish();
   }
 }