use of com.googlecode.flickrjandroid.photos.comments.Comment in project glimmr by brk3.
the class CommentsFragment method onCommentsReady.
@Override
public void onCommentsReady(List<Comment> comments, Exception e) {
mProgressBar.setVisibility(View.GONE);
if (FlickrHelper.getInstance().handleFlickrUnavailable(mActivity, e)) {
return;
}
if (comments == null) {
Log.e(TAG, "onCommentsReady: comments are null");
return;
}
if (BuildConfig.DEBUG) {
Log.d(getLogTag(), "onCommentsReady, comments.size(): " + comments.size());
}
mAdapter = new ArrayAdapter<Comment>(mActivity, R.layout.comment_list_row, (ArrayList<Comment>) comments) {
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = mActivity.getLayoutInflater().inflate(R.layout.comment_list_row, null);
holder = new ViewHolder();
holder.textViewUsername = (TextView) convertView.findViewById(R.id.userName);
holder.textViewCommentDate = (TextView) convertView.findViewById(R.id.commentDate);
holder.textViewCommentText = (TextView) convertView.findViewById(R.id.commentText);
holder.imageViewUserIcon = (ImageView) convertView.findViewById(R.id.userIcon);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final Comment comment = getItem(position);
holder.textViewUsername.setText(comment.getAuthorName());
String pTime = mPrettyTime.format(comment.getDateCreate());
/* keep Oliver happy */
if ("es".equals(Locale.getDefault().getLanguage())) {
pTime = capitaliseWord(pTime);
}
holder.textViewCommentDate.setText(pTime);
holder.textViewCommentText.setText(Html.fromHtml(comment.getText()));
String authorIcon = UrlUtilities.createBuddyIconUrl(comment.getIconFarm(), comment.getIconServer(), comment.getAuthor());
Picasso.with(mActivity).load(authorIcon).into(holder.imageViewUserIcon);
holder.imageViewUserIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent profileViewer = new Intent(mActivity, ProfileViewerActivity.class);
profileViewer.putExtra(ProfileViewerActivity.KEY_PROFILE_ID, comment.getAuthor());
profileViewer.setAction(ProfileViewerActivity.ACTION_VIEW_USER_BY_ID);
startActivity(profileViewer);
}
});
return convertView;
}
};
mListView.setAdapter(mAdapter);
}
Aggregations