use of com.uwetrottmann.trakt5.entities.Comment in project SeriesGuide by UweTrottmann.
the class TraktCommentsFragment method onListItemClick.
public void onListItemClick(ListView l, View v, int position) {
final Comment comment = (Comment) l.getItemAtPosition(position);
if (comment == null) {
return;
}
if (comment.spoiler) {
// if comment is a spoiler it is hidden, first click should reveal it
comment.spoiler = false;
TextView shoutText = (TextView) v.findViewById(R.id.textViewComment);
if (shoutText != null) {
shoutText.setText(comment.comment);
}
} else {
// open comment website
Utils.launchWebsite(getContext(), TraktLink.comment(comment.id));
}
}
use of com.uwetrottmann.trakt5.entities.Comment in project SeriesGuide by UweTrottmann.
the class TraktTask method buildComment.
private Comment buildComment() {
Comment comment = new Comment();
comment.comment = mArgs.getString(InitBundle.MESSAGE);
comment.spoiler = mArgs.getBoolean(InitBundle.ISSPOILER);
// as determined by "science", episode comments are most likely, so check for them first
// episode?
int episodeTvdbId = mArgs.getInt(InitBundle.EPISODE_TVDBID);
if (episodeTvdbId != 0) {
comment.episode = new Episode();
comment.episode.ids = EpisodeIds.tvdb(episodeTvdbId);
return comment;
}
// show?
int showTvdbId = mArgs.getInt(InitBundle.SHOW_TVDBID);
if (showTvdbId != 0) {
comment.show = new Show();
comment.show.ids = ShowIds.tvdb(showTvdbId);
return comment;
}
// movie!
int movieTmdbId = mArgs.getInt(InitBundle.MOVIE_TMDB_ID);
comment.movie = new Movie();
comment.movie.ids = MovieIds.tmdb(movieTmdbId);
return comment;
}
use of com.uwetrottmann.trakt5.entities.Comment in project SeriesGuide by UweTrottmann.
the class TraktCommentsAdapter method getView.
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
// A ViewHolder keeps references to children views to avoid
// unnecessary calls to findViewById() on each row.
TraktCommentsAdapter.ViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.item_comment, parent, false);
holder = new ViewHolder();
holder.username = (TextView) convertView.findViewById(R.id.textViewCommentUsername);
holder.comment = (TextView) convertView.findViewById(R.id.textViewComment);
holder.timestamp = (TextView) convertView.findViewById(R.id.textViewCommentTimestamp);
holder.replies = (TextView) convertView.findViewById(R.id.textViewCommentReplies);
holder.avatar = (ImageView) convertView.findViewById(R.id.imageViewCommentAvatar);
convertView.setTag(holder);
} else {
holder = (TraktCommentsAdapter.ViewHolder) convertView.getTag();
}
// Bind the data efficiently with the holder.
final Comment comment = getItem(position);
if (comment == null) {
return convertView;
}
String name = null;
String avatarPath = null;
if (comment.user != null) {
name = comment.user.username;
if (comment.user.images != null && comment.user.images.avatar != null) {
avatarPath = comment.user.images.avatar.full;
}
}
holder.username.setText(name);
ServiceUtils.loadWithPicasso(getContext(), avatarPath).into(holder.avatar);
if (comment.spoiler) {
holder.comment.setText(R.string.isspoiler);
TextViewCompat.setTextAppearance(holder.comment, R.style.TextAppearance_Body_Highlight_Red);
} else {
holder.comment.setText(comment.comment);
TextViewCompat.setTextAppearance(holder.comment, R.style.TextAppearance_Body);
}
String timestamp = (String) DateUtils.getRelativeTimeSpanString(comment.created_at.getMillis(), System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL);
holder.timestamp.setText(timestamp);
if (comment.replies == null || comment.replies <= 0) {
// no replies
holder.replies.setVisibility(View.GONE);
} else {
holder.replies.setVisibility(View.VISIBLE);
holder.replies.setText(getContext().getResources().getQuantityString(R.plurals.replies_plural, comment.replies, comment.replies));
}
return convertView;
}
Aggregations