コード例 #1
0
  @Override
  public void onFriendshipDestoryed(WeiBoUser targetUser) {
    if (mFriendship != null) mFriendship.getSource().setFollowing(false);

    mGroupMemberListed = null;

    mUser.setRemark("");
    if (mNewUser != null) mNewUser.setRemark("");

    setProfileView();

    getActivity().invalidateOptionsMenu();

    getAdapter().notifyDataSetChanged();
  }
コード例 #2
0
  @Override
  public void onFriendshipCreated(WeiBoUser targetUser) {
    if (mFriendship != null) mFriendship.getSource().setFollowing(true);

    mUser.setRecentStatusId(targetUser.getRecentStatusId());
    if (mNewUser != null) mNewUser.setRecentStatusId(targetUser.getRecentStatusId());

    mGroupMemberListed = new GroupMemberListed();
    mGroupMemberListed.setLists(new ArrayList<GroupListed>());
    mGroupMemberListed.setUid(mUser.getIdstr());

    setProfileView();

    setGroupList();

    getActivity().invalidateOptionsMenu();

    getAdapter().notifyDataSetChanged();
  }
コード例 #3
0
    @Override
    public FriendshipShow workInBackground(Void... params) throws TaskException {
      FriendshipShow friendshipShow =
          SinaSDK.getInstance(AppContext.getToken())
              .friendshipsShow(AppContext.getUser().getIdstr(), mUser.getIdstr());

      if (friendshipShow.getSource().getFollowing()) {
        GroupMemberListed[] result =
            SinaSDK.getInstance(AppContext.getToken()).friendshipGroupsListed(mUser.getIdstr());
        if (result != null && result.length > 0) {
          mGroupMemberListed = result[0];
        } else {
          mGroupMemberListed = new GroupMemberListed();
          mGroupMemberListed.setLists(new ArrayList<GroupListed>());
          mGroupMemberListed.setUid(mUser.getId());
        }
      }

      return friendshipShow;
    }
コード例 #4
0
  @Override
  public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    MenuItem mentionItem = menu.findItem(R.id.mention);
    MenuItem createItem = menu.findItem(R.id.create);
    MenuItem destoryItem = menu.findItem(R.id.destory);
    MenuItem followerDestoryItem = menu.findItem(R.id.followDestory);

    if (mUser == null || AppContext.getUser().getIdstr().equals(mUser.getIdstr())) {
      mentionItem.setVisible(false);
      createItem.setVisible(false);
      destoryItem.setVisible(false);
      followerDestoryItem.setVisible(false);
    } else {
      mentionItem.setVisible(true);

      createItem.setVisible(mFriendship != null && !mFriendship.getSource().getFollowing());
      destoryItem.setVisible(mFriendship != null && mFriendship.getSource().getFollowing());

      followerDestoryItem.setVisible(mFriendship != null && mFriendship.getTarget().getFollowing());
    }
  }
コード例 #5
0
  private void setProfileView() {
    ImageView imgPhoto = (ImageView) viewProfile.findViewById(R.id.imgPhoto);
    BitmapLoader.getInstance()
        .display(
            this, AisenUtil.getUserPhoto(mUser), imgPhoto, ImageConfigUtils.getLargePhotoConfig());

    TextView txtName = (TextView) viewProfile.findViewById(R.id.txtName);
    txtName.setText(mUser.getName());
    // f**k 2014-09-04 当名字过长大于6个字时,截取部分文字
    int maxLength = AisenUtil.getStrLength("当名字过长大于个");
    if (AisenUtil.getStrLength(mUser.getName()) > maxLength) {
      StringBuffer sb = new StringBuffer();
      int index = 0;
      while (AisenUtil.getStrLength(sb.toString()) < maxLength) {
        if (index >= mUser.getName().length()) break;

        sb.append(mUser.getName().charAt(index));
        index++;
      }
      sb.append("...");
      txtName.setText(sb.toString());
    }

    // 性别
    ImageView imgGender = (ImageView) viewProfile.findViewById(R.id.imgGender);
    imgGender.setVisibility(View.VISIBLE);
    if ("m".equals(mUser.getGender())) imgGender.setImageResource(R.drawable.list_male);
    else if ("f".equals(mUser.getGender())) imgGender.setImageResource(R.drawable.list_female);
    else imgGender.setVisibility(View.GONE);

    // 认证
    ImageView imgVerified = (ImageView) viewProfile.findViewById(R.id.imgVerified);
    AisenUtil.setImageVerified(imgVerified, mUser);

    // 简介
    TextView txtDesc = (TextView) viewProfile.findViewById(R.id.txtDesc);
    if (!TextUtils.isEmpty(mUser.getDescription()))
      txtDesc.setText(String.format(getString(R.string.profile_des_hint), mUser.getDescription()));
    else
      txtDesc.setText(
          String.format(
              String.format(
                  getString(R.string.profile_des_hint), getString(R.string.profile_des_none))));

    // 认证原因
    TextView txtVerifiedReason = (TextView) viewProfile.findViewById(R.id.txtVerifiedReason);
    txtVerifiedReason.setVisibility(
        !TextUtils.isEmpty(mUser.getVerified_reason()) ? View.VISIBLE : View.GONE);
    txtVerifiedReason.setText(
        String.format(getString(R.string.profile_ver_reason), mUser.getVerified_reason() + ""));

    // 备注
    TextView txtRemark = (TextView) viewProfile.findViewById(R.id.txtRemark);
    txtRemark.setVisibility(
        mFriendship == null || !mFriendship.getSource().getFollowing() ? View.GONE : View.VISIBLE);
    if (mFriendship != null) {
      try {
        BizFragment.getBizFragment(this).modifyUserMark(txtRemark, mUser, this);
      } catch (Exception e) {
      }
      if (!TextUtils.isEmpty(mUser.getRemark()))
        txtRemark.setText(String.format(getString(R.string.profile_remark), mUser.getRemark()));
      else txtRemark.setText(R.string.profile_remark_none);
    }

    // 分组
    TextView txtGroups = (TextView) viewProfile.findViewById(R.id.txtGroups);
    txtGroups.setVisibility(mGroupMemberListed == null ? View.GONE : View.VISIBLE);
    txtGroups.setOnClickListener(this);
    if (mGroupMemberListed != null) {
      if (mGroupMemberListed.getLists().size() == 0) {
        txtGroups.setText(R.string.profile_group_none);
      } else {
        StringBuffer sb = new StringBuffer();
        for (GroupListed groupListed : mGroupMemberListed.getLists())
          sb.append(groupListed.getName()).append(" ");

        txtGroups.setText(
            String.format(getString(R.string.profile_group_hint), sb.toString().trim()));
      }
    }

    // 所在地
    TextView txtLocation = (TextView) viewProfile.findViewById(R.id.txtLocation);
    txtLocation.setText(mUser.getLocation());

    // 微博数
    TextView txtStatusCount = (TextView) viewProfile.findViewById(R.id.txtStatusCount);
    txtStatusCount.setText(AisenUtil.getCounter(mUser.getStatuses_count()));

    // 关注数
    viewProfile.findViewById(R.id.btnFriendCounter).setOnClickListener(this);
    TextView txtFriendCount = (TextView) viewProfile.findViewById(R.id.txtFriendCount);
    txtFriendCount.setText(AisenUtil.getCounter(mUser.getFriends_count()));

    // 粉丝数
    viewProfile.findViewById(R.id.btnFollowerCounter).setOnClickListener(this);
    TextView txtFollowerCount = (TextView) viewProfile.findViewById(R.id.txtFollowerCount);
    txtFollowerCount.setText(AisenUtil.getCounter(mUser.getFollowers_count()));
  }