public static LocalStatus createDividerStatus(List<Status> statusList, LocalAccount account) { if (ListUtil.isEmpty(statusList) || account == null) { return null; } Status status = statusList.get(statusList.size() - 1); StringBuffer newId = new StringBuffer(status.getStatusId()); char c = newId.charAt(newId.length() - 1); byte b = (byte) ((int) c - 1); newId.setCharAt(newId.length() - 1, (char) b); LocalStatus dividerStatus = new LocalStatus(); dividerStatus.setStatusId(newId.toString()); dividerStatus.setAccountId(account.getAccountId()); dividerStatus.setServiceProvider(account.getServiceProvider()); Date createdAt = new Date(status.getCreatedAt().getTime() - 1); dividerStatus.setCreatedAt(createdAt); dividerStatus.setDivider(true); dividerStatus.setText("divider"); return dividerStatus; }
public static View fillConvertView(View convertView, Status status) { if (convertView == null || status == null) { return null; } Context context = convertView.getContext(); StatusHolder holder = (StatusHolder) convertView.getTag(); if (holder == null) { return null; } holder.reset(); boolean isNetEase = status.getServiceProvider() == ServiceProvider.NetEase; User user = status.getUser(); if (user == null) { // 微博已经删除 if (StringUtil.isNotEmpty(status.getText())) { Spannable textSpan = EmotionLoader.getEmotionSpannable(status.getServiceProvider(), status.getText()); holder.tvText.setText(textSpan); } return convertView; } if (GlobalVars.IS_SHOW_HEAD) { holder.ivProfilePicture.setVisibility(View.VISIBLE); holder.headClickListener.setUser(user); String profileUrl = user.getProfileImageUrl(); if (StringUtil.isNotEmpty(profileUrl)) { ImageLoad4HeadTask headTask = new ImageLoad4HeadTask(holder.ivProfilePicture, profileUrl, true); holder.headTask = headTask; headTask.execute(); } } else { holder.ivProfilePicture.setVisibility(View.GONE); } holder.tvScreenName.setText(user.getScreenName()); if (status.getUser().isVerified()) { holder.ivVerify.setVisibility(View.VISIBLE); } if (status.getLocation() != null) { holder.ivLocation.setVisibility(View.VISIBLE); } if (status.isFavorited()) { holder.ivFavorite.setVisibility(View.VISIBLE); } holder.tvCreatedAt.setText(TimeSpanUtil.toTimeSpanString(status.getCreatedAt())); Spannable textSpan = EmotionLoader.getEmotionSpannable(status.getServiceProvider(), status.getText()); holder.tvText.setText(textSpan); Status retweet = status.getRetweetedStatus(); if (retweet != null) { holder.llRetweet.setVisibility(View.VISIBLE); holder.tvRetweetText.setVisibility(View.VISIBLE); String retweetText = ""; if (retweet.getUser() != null) { retweetText = retweet.getUser().getMentionTitleName() + ": " + retweet.getText(); } Spannable retweetTextSpan = EmotionLoader.getEmotionSpannable(status.getServiceProvider(), retweetText); holder.tvRetweetText.setText(retweetTextSpan); } String thumbnailUrl = status.getThumbnailPictureUrl(); ImageView ivTempThumbnail = holder.ivThumbnail; if (retweet != null) { thumbnailUrl = retweet.getThumbnailPictureUrl(); ivTempThumbnail = holder.ivRetweetThumbnail; } if (StringUtil.isNotEmpty(thumbnailUrl)) { holder.ivAttachment.setVisibility(View.VISIBLE); if (GlobalVars.IS_SHOW_THUMBNAIL && !isNetEase) { ivTempThumbnail.setVisibility(View.VISIBLE); ImageLoad4ThumbnailTask thumbnailTask = new ImageLoad4ThumbnailTask(ivTempThumbnail, thumbnailUrl); holder.thumbnailTask = thumbnailTask; // thumbnailTask.execute(status); ivTempThumbnail.setOnClickListener(new ImageClickListener(status)); } } String source = String.format(GlobalResource.getStatusSourceFormat(context), status.getSource()); holder.tvSource.setText(Html.fromHtml(source).toString()); String responseFormat = GlobalResource.getStatusResponseFormat(context); int retweetCount = status.getRetweetCount() == null ? 0 : status.getRetweetCount(); int commentCount = status.getCommentCount() == null ? 0 : status.getCommentCount(); String responseText = String.format(responseFormat, retweetCount, commentCount); holder.tvResponse.setText(responseText); if (status.getRetweetCount() == null || status.getRetweetCount() != null) { holder.tvResponse.setText(responseText); QueryResponseCountTask responseCountTask = new QueryResponseCountTask(context, status, holder.tvResponse); holder.responseCountTask = responseCountTask; // countTask.execute(); } return convertView; }