Search in sources :

Example 1 with Comment

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);
}
Also used : Comment(com.googlecode.flickrjandroid.photos.comments.Comment) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Aggregations

Intent (android.content.Intent)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 Comment (com.googlecode.flickrjandroid.photos.comments.Comment)1 ArrayList (java.util.ArrayList)1