@Override protected void initRefreshList(Bundle savedInstanceState) { super.initRefreshList(savedInstanceState); ListView listView = (ListView) getRefreshView(); viewProfile = View.inflate(getActivity(), R.layout.lay_profile_v2, null); AisenUtil.setAlpha(viewProfile); listView.addHeaderView(viewProfile); }
@Override public String getLastReadKey() { return AisenUtil.getUserKey(mGroupBean.getGroup(), loggedIn); }
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())); }