Search in sources :

Example 51 with SpannableStringBuilder

use of android.text.SpannableStringBuilder in project Signal-Android by WhisperSystems.

the class SingleRecipientNotificationBuilder method setPrimaryMessageBody.

public void setPrimaryMessageBody(@NonNull Recipients threadRecipients, @NonNull Recipient individualRecipient, @NonNull CharSequence message, @Nullable SlideDeck slideDeck) {
    SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
    if (privacy.isDisplayContact() && (threadRecipients.isGroupRecipient() || !threadRecipients.isSingleRecipient())) {
        stringBuilder.append(Util.getBoldedString(individualRecipient.toShortString() + ": "));
    }
    if (privacy.isDisplayMessage()) {
        setContentText(stringBuilder.append(message));
        this.slideDeck = slideDeck;
    } else {
        setContentText(stringBuilder.append(context.getString(R.string.SingleRecipientNotificationBuilder_new_message)));
    }
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 52 with SpannableStringBuilder

use of android.text.SpannableStringBuilder in project Signal-Android by WhisperSystems.

the class SingleRecipientNotificationBuilder method getBigText.

private CharSequence getBigText(List<CharSequence> messageBodies) {
    SpannableStringBuilder content = new SpannableStringBuilder();
    for (CharSequence message : messageBodies) {
        content.append(message);
        content.append('\n');
    }
    return content;
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 53 with SpannableStringBuilder

use of android.text.SpannableStringBuilder in project Klyph by jonathangerbaud.

the class CommentAdapter method mergeViewWithData.

@Override
protected void mergeViewWithData(View view, GraphObject data) {
    super.mergeViewWithData(view, data);
    Comment comment = (Comment) data;
    final CommentHolder holder = (CommentHolder) getHolder(view);
    holder.getDepthBar().setVisibility(comment.hasParentComment() ? View.VISIBLE : View.GONE);
    holder.getAuthorName().setAutoLinkMask(0);
    holder.getAuthorName().setText("");
    String name = comment.getFrom().getName();
    String time = DateUtil.timeAgoInWords(getContext(view), comment.getCreated_time());
    String text = name + "  " + time + "  ";
    holder.getAuthorName().setText(text);
    TextViewUtil.setElementClickable(getContext(view), holder.getAuthorName(), comment.getFrom().getName(), comment.getFrom().getId(), "user", false);
    Spannable styledText = new SpannableString(holder.getAuthorName().getText());
    TextAppearanceSpan span1 = new TextAppearanceSpan(getContext(holder.getAuthorName()), R.style.Klyph_CommentTextName);
    TextAppearanceSpan span2 = new TextAppearanceSpan(getContext(holder.getAuthorName()), R.style.Klyph_CommentTextTime);
    if (Android.isMinAPI(11))
        styledText.setSpan(span1, 0, name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    styledText.setSpan(span2, name.length() + 2, name.length() + 2 + time.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    holder.getAuthorName().setText(styledText);
    String commentText = comment.getMessage();
    int numLikes = comment.getLike_count();
    if (numLikes > 0) {
        if (commentText.length() > 0)
            commentText += "  ";
        commentText += numLikes + "  ";
    }
    final SpannableStringBuilder sb = new SpannableStringBuilder();
    sb.append(commentText);
    if (numLikes > 0) {
        ImageSpan span3 = new ImageSpan(getContext(holder.getAuthorName()), AttrUtil.getResourceId(getContext(holder.getAuthorName()), comment.getUser_likes() ? R.attr.userLikeSmallIcon : R.attr.likeIconSmall), DynamicDrawableSpan.ALIGN_BASELINE);
        TextAppearanceSpan span4 = new TextAppearanceSpan(getContext(holder.getAuthorName()), R.style.Klyph_CommentTextTime);
        int likesLength = String.valueOf(numLikes).length();
        sb.setSpan(span3, commentText.length() - 2, commentText.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        sb.setSpan(span4, commentText.length() - (likesLength + 2), commentText.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    holder.getCommentText().setText(sb);
    if (placeHolder == -1)
        placeHolder = KlyphUtil.getPlaceHolder(view.getContext());
    if (profilePlaceHolder == -1)
        profilePlaceHolder = KlyphUtil.getProfilePlaceHolder(view.getContext());
    ((ProfileImageView) holder.getAuthorPicture()).disableBorder();
    String url = comment.getFrom().getPicture().getUrl();
    loadImage(holder.getAuthorPicture(), url, profilePlaceHolder, data);
    holder.getCommentImage().setOnClickListener(null);
    holder.getCommentLinkImage().setOnClickListener(null);
    if (comment.getAttachment().isPhoto() || comment.getAttachment().isVideoShare()) {
        Image image = comment.getAttachment().getMedia().getImage();
        RatioImageView rImageview = (RatioImageView) holder.getCommentImage();
        rImageview.setImageSize(image.getWidth(), image.getHeight());
        int parentWidth = ((ViewGroup) holder.getCommentImage().getParent()).getWidth();
        if (parentWidth > 0) {
            LayoutParams params = holder.getCommentImage().getLayoutParams();
            params.width = Math.min(parentWidth, image.getWidth());
            holder.getCommentImage().setLayoutParams(params);
        }
        loadImage(holder.getCommentImage(), image.getSrc(), placeHolder, data);
        final Target target = comment.getAttachment().getTarget();
        holder.getCommentLinkImage().setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getContext(holder.getCommentImage()), ImageActivity.class);
                intent.putExtra(KlyphBundleExtras.PHOTO_ID, target.getId());
                getContext(holder.getCommentLinkImage()).startActivity(intent);
            }
        });
    } else if (comment.getAttachment().isShare()) {
        final Attachment att = comment.getAttachment();
        Image image = comment.getAttachment().getMedia().getImage();
        holder.getCommentLinkImageBackground().setColorFilter(colorFilter, PorterDuff.Mode.SRC_OVER);
        loadImage(holder.getCommentLinkImage(), image.getSrc(), placeHolder, data);
        loadImage(holder.getCommentLinkImageBackground(), image.getSrc(), placeHolder, data);
        holder.getCommentLinkName().setText(att.getTitle());
        holder.getCommentLinkUrl().setText(att.getUrl());
        holder.getCommentLinkDescription().setText(att.getDescription());
        holder.getCommentLinkImage().setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                PhoneUtil.openURL(getContext(holder.getCommentLinkImage()), att.getUrl());
            }
        });
    }
    if (comment.getAttachment().isVideoShare())
        holder.getCommentImagePlay().setVisibility(View.VISIBLE);
    else
        holder.getCommentImagePlay().setVisibility(View.GONE);
    ((View) holder.getCommentImage().getParent()).setVisibility(comment.getAttachment().isPhoto() || comment.getAttachment().isVideoShare() ? View.VISIBLE : View.GONE);
    ((View) holder.getCommentLinkImage().getParent()).setVisibility(comment.getAttachment().isShare() ? View.VISIBLE : View.GONE);
}
Also used : Comment(com.abewy.android.apps.klyph.core.graph.Comment) ProfileImageView(com.abewy.android.apps.klyph.widget.ProfileImageView) TextAppearanceSpan(android.text.style.TextAppearanceSpan) LayoutParams(android.view.ViewGroup.LayoutParams) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) Attachment(com.abewy.android.apps.klyph.core.graph.Comment.Attachment) SpannableString(android.text.SpannableString) Image(com.abewy.android.apps.klyph.core.graph.Comment.Attachment.Media.Image) ImageView(android.widget.ImageView) View(android.view.View) ProfileImageView(com.abewy.android.apps.klyph.widget.ProfileImageView) TextView(android.widget.TextView) RatioImageView(com.abewy.android.extended.widget.RatioImageView) SpannableString(android.text.SpannableString) ImageActivity(com.abewy.android.apps.klyph.app.ImageActivity) Target(com.abewy.android.apps.klyph.core.graph.Comment.Attachment.Target) RatioImageView(com.abewy.android.extended.widget.RatioImageView) CommentHolder(com.abewy.android.apps.klyph.adapter.holder.CommentHolder) Spannable(android.text.Spannable) SpannableStringBuilder(android.text.SpannableStringBuilder) ImageSpan(android.text.style.ImageSpan)

Example 54 with SpannableStringBuilder

use of android.text.SpannableStringBuilder in project Klyph by jonathangerbaud.

the class CommentAdapter method mergeViewWithData.

@Override
protected void mergeViewWithData(View view, GraphObject data) {
    super.mergeViewWithData(view, data);
    Comment comment = (Comment) data;
    final CommentHolder holder = (CommentHolder) getHolder(view);
    holder.getDepthBar().setVisibility(comment.hasParentComment() ? View.VISIBLE : View.GONE);
    holder.getAuthorName().setAutoLinkMask(0);
    holder.getAuthorName().setText("");
    String name = comment.getFrom_name();
    String time = DateUtil.timeAgoInWords(getContext(view), comment.getTime());
    String text = name + "  " + time + "  ";
    holder.getAuthorName().setText(text);
    TextViewUtil.setElementClickable(getContext(view), holder.getAuthorName(), comment.getFrom_name(), comment.getFromid(), comment.getFrom_type(), true);
    Spannable styledText = new SpannableString(holder.getAuthorName().getText());
    TextAppearanceSpan span1 = new TextAppearanceSpan(getContext(holder.getAuthorName()), R.style.Klyph_CommentTextName);
    TextAppearanceSpan span2 = new TextAppearanceSpan(getContext(holder.getAuthorName()), R.style.Klyph_CommentTextTime);
    if (Android.isMinAPI(11))
        styledText.setSpan(span1, 0, name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    styledText.setSpan(span2, name.length() + 2, name.length() + 2 + time.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    holder.getAuthorName().setText(styledText);
    String commentText = comment.getText();
    int numLikes = comment.getLikes();
    if (numLikes > 0) {
        if (commentText.length() > 0)
            commentText += "  ";
        commentText += numLikes + "  ";
    }
    final SpannableStringBuilder sb = new SpannableStringBuilder();
    sb.append(commentText);
    if (numLikes > 0) {
        ImageSpan span3 = new ImageSpan(getContext(holder.getAuthorName()), AttrUtil.getResourceId(getContext(holder.getAuthorName()), comment.getUser_likes() ? R.attr.userLikeSmallIcon : R.attr.likeIconSmall), DynamicDrawableSpan.ALIGN_BASELINE);
        TextAppearanceSpan span4 = new TextAppearanceSpan(getContext(holder.getAuthorName()), R.style.Klyph_CommentTextTime);
        int likesLength = String.valueOf(numLikes).length();
        sb.setSpan(span3, commentText.length() - 2, commentText.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        sb.setSpan(span4, commentText.length() - (likesLength + 2), commentText.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    holder.getCommentText().setText(sb);
    if (placeHolder == -1)
        placeHolder = AttrUtil.getResourceId(getContext(holder.getAuthorName()), R.attr.squarePlaceHolderIcon);
    if (profilePlaceHolder == -1)
        profilePlaceHolder = AttrUtil.getResourceId(getContext(holder.getAuthorName()), R.attr.circlePlaceHolderIcon);
    String url = comment.getFrom_pic();
    loadImage(holder.getAuthorPicture(), "http://www.google.com/abc/9.jpg", profilePlaceHolder, data);
    holder.getCommentImage().setOnClickListener(null);
    holder.getCommentLinkImage().setOnClickListener(null);
    if (comment.getAttachment().isPhoto()) {
        Image image = comment.getAttachment().getMedia().getImage();
        RatioImageView rImageView = (RatioImageView) holder.getCommentImage();
        rImageView.setImageSize(image.getWidth(), image.getHeight());
        loadImage(holder.getCommentImage(), image.getSrc(), placeHolder, data);
        final Target target = comment.getAttachment().getTarget();
        holder.getCommentLinkImage().setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getContext(holder.getCommentImage()), ImageActivity.class);
                intent.putExtra(KlyphBundleExtras.PHOTO_ID, target.getId());
                getContext(holder.getCommentLinkImage()).startActivity(intent);
            }
        });
    } else if (comment.getAttachment().isShare()) {
        final Attachment att = comment.getAttachment();
        Image image = comment.getAttachment().getMedia().getImage();
        holder.getCommentLinkImageBackground().setColorFilter(colorFilter, PorterDuff.Mode.SRC_OVER);
        loadImage(holder.getCommentLinkImage(), image.getSrc(), placeHolder, data);
        loadImage(holder.getCommentLinkImageBackground(), image.getSrc(), placeHolder, data);
        holder.getCommentLinkName().setText(att.getTitle());
        holder.getCommentLinkUrl().setText(att.getUrl());
        holder.getCommentLinkDescription().setText(att.getDescription());
        holder.getCommentLinkImage().setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                PhoneUtil.openURL(getContext(holder.getCommentLinkImage()), att.getUrl());
            }
        });
    }
    holder.getCommentImage().setVisibility(comment.getAttachment().isPhoto() ? View.VISIBLE : View.GONE);
    ((View) holder.getCommentLinkImage().getParent()).setVisibility(comment.getAttachment().isShare() ? View.VISIBLE : View.GONE);
}
Also used : Comment(com.abewy.android.apps.klyph.core.fql.Comment) TextAppearanceSpan(android.text.style.TextAppearanceSpan) Intent(android.content.Intent) Attachment(com.abewy.android.apps.klyph.core.fql.Comment.Attachment) SpannableString(android.text.SpannableString) Image(com.abewy.android.apps.klyph.core.fql.Comment.Attachment.Media.Image) ImageView(android.widget.ImageView) View(android.view.View) ProfileImageView(com.abewy.android.apps.klyph.widget.ProfileImageView) TextView(android.widget.TextView) RatioImageView(com.abewy.android.extended.widget.RatioImageView) SpannableString(android.text.SpannableString) ImageActivity(com.abewy.android.apps.klyph.app.ImageActivity) Target(com.abewy.android.apps.klyph.core.fql.Comment.Attachment.Target) RatioImageView(com.abewy.android.extended.widget.RatioImageView) CommentHolder(com.abewy.android.apps.klyph.adapter.holder.CommentHolder) Spannable(android.text.Spannable) SpannableStringBuilder(android.text.SpannableStringBuilder) ImageSpan(android.text.style.ImageSpan)

Example 55 with SpannableStringBuilder

use of android.text.SpannableStringBuilder in project SeriesGuide by UweTrottmann.

the class EpisodeDetailsFragment method populateEpisodeData.

private void populateEpisodeData(Cursor cursor) {
    if (cursor == null || !cursor.moveToFirst()) {
        // no data to display
        if (mEpisodeContainer != null) {
            mEpisodeContainer.setVisibility(View.GONE);
        }
        return;
    }
    mShowTvdbId = cursor.getInt(DetailsQuery.SHOW_ID);
    mSeasonNumber = cursor.getInt(DetailsQuery.SEASON);
    mEpisodeNumber = cursor.getInt(DetailsQuery.NUMBER);
    mShowRunTime = cursor.getInt(DetailsQuery.SHOW_RUNTIME);
    mEpisodeReleaseTime = cursor.getLong(DetailsQuery.FIRST_RELEASE_MS);
    // title and description
    mEpisodeFlag = cursor.getInt(DetailsQuery.WATCHED);
    mEpisodeTitle = cursor.getString(DetailsQuery.TITLE);
    boolean hideDetails = EpisodeTools.isUnwatched(mEpisodeFlag) && DisplaySettings.preventSpoilers(getContext());
    if (hideDetails) {
        // just show the episode number "1x02"
        mTitle.setText(TextTools.getEpisodeNumber(getContext(), mSeasonNumber, mEpisodeNumber));
    } else {
        mTitle.setText(mEpisodeTitle);
    }
    String overview = cursor.getString(DetailsQuery.OVERVIEW);
    if (TextUtils.isEmpty(overview)) {
        // no description available, show no translation available message
        mDescription.setText(getString(R.string.no_translation, LanguageTools.getShowLanguageStringFor(getContext(), cursor.getString(DetailsQuery.SHOW_LANGUAGE)), getString(R.string.tvdb)));
    } else {
        if (hideDetails) {
            mDescription.setText(R.string.no_spoilers);
        } else {
            mDescription.setText(overview);
        }
    }
    // show title
    mShowTitle = cursor.getString(DetailsQuery.SHOW_TITLE);
    // release date, also build release time and day
    SpannableStringBuilder timeAndNumbersText = new SpannableStringBuilder();
    if (mEpisodeReleaseTime != -1) {
        Date actualRelease = TimeTools.applyUserOffset(getContext(), mEpisodeReleaseTime);
        mReleaseDate.setText(TimeTools.formatToLocalDateAndDay(getContext(), actualRelease));
        String dateTime;
        if (DisplaySettings.isDisplayExactDate(getContext())) {
            // "31. October 2010"
            dateTime = TimeTools.formatToLocalDate(getContext(), actualRelease);
        } else {
            // "in 15 mins"
            dateTime = TimeTools.formatToLocalRelativeTime(getContext(), actualRelease);
        }
        // append day: "in 15 mins (Fri)"
        timeAndNumbersText.append(getString(R.string.release_date_and_day, dateTime, TimeTools.formatToLocalDay(actualRelease)).toUpperCase(Locale.getDefault()));
        timeAndNumbersText.append("  ");
    } else {
        mReleaseDate.setText(R.string.unknown);
    }
    // absolute number (e.g. relevant for Anime): "ABSOLUTE 142"
    int numberStartIndex = timeAndNumbersText.length();
    int absoluteNumber = cursor.getInt(DetailsQuery.NUMBER_ABSOLUTE);
    if (absoluteNumber > 0) {
        timeAndNumbersText.append(getString(R.string.episode_number_absolute)).append(" ").append(String.valueOf(absoluteNumber));
        // de-emphasize number
        timeAndNumbersText.setSpan(new TextAppearanceSpan(getActivity(), R.style.TextAppearance_Caption_Dim), numberStartIndex, timeAndNumbersText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    mReleaseTime.setText(timeAndNumbersText);
    // guest stars
    Utils.setLabelValueOrHide(mLabelGuestStars, mGuestStars, TextTools.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.GUESTSTARS)));
    // DVD episode number
    Utils.setLabelValueOrHide(mLabelDvd, mDvd, cursor.getDouble(DetailsQuery.NUMBER_DVD));
    // directors
    Utils.setValueOrPlaceholder(mDirectors, TextTools.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.DIRECTORS)));
    // writers
    Utils.setValueOrPlaceholder(mWriters, TextTools.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.WRITERS)));
    // last TVDb edit date
    long lastEditSeconds = cursor.getLong(DetailsQuery.LAST_EDITED);
    if (lastEditSeconds > 0) {
        mLastEdit.setText(DateUtils.formatDateTime(getActivity(), lastEditSeconds * 1000, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME));
    } else {
        mLastEdit.setText(R.string.unknown);
    }
    // ratings
    mRatingsContainer.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            rateEpisode();
        }
    });
    CheatSheet.setup(mRatingsContainer, R.string.action_rate);
    // trakt rating
    mTextRating.setText(TraktTools.buildRatingString(cursor.getDouble(DetailsQuery.RATING_GLOBAL)));
    mTextRatingVotes.setText(TraktTools.buildRatingVotesString(getActivity(), cursor.getInt(DetailsQuery.RATING_VOTES)));
    // user rating
    mTextUserRating.setText(TraktTools.buildUserRatingString(getActivity(), cursor.getInt(DetailsQuery.RATING_USER)));
    loadTraktRatings();
    // episode image
    final String imagePath = cursor.getString(DetailsQuery.IMAGE);
    mImageContainer.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), FullscreenImageActivity.class);
            intent.putExtra(FullscreenImageActivity.EXTRA_IMAGE, TvdbImageTools.fullSizeUrl(imagePath));
            Utils.startActivityWithAnimation(getActivity(), intent, v);
        }
    });
    loadImage(imagePath, hideDetails);
    // check in button
    final int episodeTvdbId = cursor.getInt(DetailsQuery._ID);
    buttonCheckin.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // display a check-in dialog
            CheckInDialogFragment f = CheckInDialogFragment.newInstance(getActivity(), episodeTvdbId);
            if (f != null && isResumed()) {
                f.show(getFragmentManager(), "checkin-dialog");
                Utils.trackAction(getActivity(), TAG, "Check-In");
            }
        }
    });
    CheatSheet.setup(buttonCheckin);
    // hide check-in if not connected to trakt or hexagon is enabled
    boolean isConnectedToTrakt = TraktCredentials.get(getActivity()).hasCredentials();
    boolean displayCheckIn = isConnectedToTrakt && !HexagonSettings.isEnabled(getActivity());
    buttonCheckin.setVisibility(displayCheckIn ? View.VISIBLE : View.GONE);
    dividerEpisodeButtons.setVisibility(displayCheckIn ? View.VISIBLE : View.GONE);
    // watched button
    boolean isWatched = EpisodeTools.isWatched(mEpisodeFlag);
    Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(buttonWatch, 0, isWatched ? Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatched) : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatch), 0, 0);
    buttonWatch.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            onToggleWatched();
            Utils.trackAction(getActivity(), TAG, "Toggle watched");
        }
    });
    buttonWatch.setText(isWatched ? R.string.action_unwatched : R.string.action_watched);
    CheatSheet.setup(buttonWatch, isWatched ? R.string.action_unwatched : R.string.action_watched);
    // collected button
    mCollected = cursor.getInt(DetailsQuery.COLLECTED) == 1;
    Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(buttonCollect, 0, mCollected ? R.drawable.ic_collected : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableCollect), 0, 0);
    buttonCollect.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            onToggleCollected();
            Utils.trackAction(getActivity(), TAG, "Toggle collected");
        }
    });
    buttonCollect.setText(mCollected ? R.string.action_collection_remove : R.string.action_collection_add);
    CheatSheet.setup(buttonCollect, mCollected ? R.string.action_collection_remove : R.string.action_collection_add);
    // skip button
    boolean isSkipped = EpisodeTools.isSkipped(mEpisodeFlag);
    if (isWatched) {
        // if watched do not allow skipping
        buttonSkip.setVisibility(View.INVISIBLE);
    } else {
        buttonSkip.setVisibility(View.VISIBLE);
        Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(buttonSkip, 0, isSkipped ? R.drawable.ic_skipped : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableSkip), 0, 0);
        buttonSkip.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                onToggleSkipped();
                Utils.trackAction(getActivity(), TAG, "Toggle skipped");
            }
        });
        buttonSkip.setText(isSkipped ? R.string.action_dont_skip : R.string.action_skip);
        CheatSheet.setup(buttonSkip, isSkipped ? R.string.action_dont_skip : R.string.action_skip);
    }
    // service buttons
    ServiceUtils.setUpTraktEpisodeButton(mTraktButton, getEpisodeTvdbId(), TAG);
    // IMDb
    String imdbId = cursor.getString(DetailsQuery.IMDBID);
    if (TextUtils.isEmpty(imdbId)) {
        // fall back to show IMDb id
        imdbId = cursor.getString(DetailsQuery.SHOW_IMDBID);
    }
    ServiceUtils.setUpImdbButton(imdbId, mImdbButton, TAG);
    // TVDb
    final int seasonTvdbId = cursor.getInt(DetailsQuery.SEASON_ID);
    ServiceUtils.setUpTvdbButton(mShowTvdbId, seasonTvdbId, getEpisodeTvdbId(), mTvdbButton, TAG);
    // trakt comments
    mCommentsButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), TraktCommentsActivity.class);
            intent.putExtras(TraktCommentsActivity.createInitBundleEpisode(mEpisodeTitle, getEpisodeTvdbId()));
            Utils.startActivityWithAnimation(getActivity(), intent, v);
            Utils.trackAction(v.getContext(), TAG, "Comments");
        }
    });
    mEpisodeContainer.setVisibility(View.VISIBLE);
}
Also used : TextAppearanceSpan(android.text.style.TextAppearanceSpan) Intent(android.content.Intent) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) Date(java.util.Date) OnClickListener(android.view.View.OnClickListener) SpannableStringBuilder(android.text.SpannableStringBuilder) CheckInDialogFragment(com.battlelancer.seriesguide.ui.dialogs.CheckInDialogFragment)

Aggregations

SpannableStringBuilder (android.text.SpannableStringBuilder)336 ForegroundColorSpan (android.text.style.ForegroundColorSpan)56 ImageSpan (android.text.style.ImageSpan)53 TextView (android.widget.TextView)40 View (android.view.View)38 StyleSpan (android.text.style.StyleSpan)35 Spanned (android.text.Spanned)28 Drawable (android.graphics.drawable.Drawable)27 Spannable (android.text.Spannable)25 SpannableString (android.text.SpannableString)21 Test (org.junit.Test)21 CharacterStyle (android.text.style.CharacterStyle)18 TextPaint (android.text.TextPaint)17 RelativeSizeSpan (android.text.style.RelativeSizeSpan)17 Paint (android.graphics.Paint)16 Context (android.content.Context)15 TextAppearanceSpan (android.text.style.TextAppearanceSpan)15 ImageView (android.widget.ImageView)15 Intent (android.content.Intent)13 Editable (android.text.Editable)13