Search in sources :

Example 1 with Comment

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));
    }
}
Also used : Comment(com.uwetrottmann.trakt5.entities.Comment) TextView(android.widget.TextView)

Example 2 with Comment

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;
}
Also used : Comment(com.uwetrottmann.trakt5.entities.Comment) Episode(com.uwetrottmann.trakt5.entities.Episode) SyncEpisode(com.uwetrottmann.trakt5.entities.SyncEpisode) SyncMovie(com.uwetrottmann.trakt5.entities.SyncMovie) Movie(com.uwetrottmann.trakt5.entities.Movie) Show(com.uwetrottmann.trakt5.entities.Show)

Example 3 with 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;
}
Also used : Comment(com.uwetrottmann.trakt5.entities.Comment) NonNull(android.support.annotation.NonNull)

Aggregations

Comment (com.uwetrottmann.trakt5.entities.Comment)3 NonNull (android.support.annotation.NonNull)1 TextView (android.widget.TextView)1 Episode (com.uwetrottmann.trakt5.entities.Episode)1 Movie (com.uwetrottmann.trakt5.entities.Movie)1 Show (com.uwetrottmann.trakt5.entities.Show)1 SyncEpisode (com.uwetrottmann.trakt5.entities.SyncEpisode)1 SyncMovie (com.uwetrottmann.trakt5.entities.SyncMovie)1