List of usage examples for android.text.style TextAppearanceSpan TextAppearanceSpan
public TextAppearanceSpan(Context context, int appearance)
From source file:com.heath_bar.tvdb.SeriesOverview.java
/** Populate the interface with the data pulled from the webz */ private void PopulateStuff(TvSeries seriesInfo) { if (seriesInfo == null) { Toast.makeText(getApplicationContext(), "Something bad happened. No data was found.", Toast.LENGTH_SHORT).show(); return;/*from w w w . j a v a 2s. c om*/ } // Set title getSupportActionBar().setTitle(seriesInfo.getName()); // Hide/Activate the favorites button if (seriesInfo.isFavorite(getApplicationContext())) { Button b = (Button) findViewById(R.id.btn_add_to_favorites); b.setVisibility(View.GONE); } else { Button b = (Button) findViewById(R.id.btn_add_to_favorites); b.setVisibility(View.VISIBLE); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Button b = (Button) findViewById(R.id.btn_add_to_favorites); b.setVisibility(View.GONE); addToFavorites(); } }); } // Set the banner ImageView imageView = (ImageView) findViewById(R.id.series_banner); imageView.setImageBitmap(seriesInfo.getImage().getBitmap()); imageView.setVisibility(View.VISIBLE); final String seriesName = seriesInfo.getName(); imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { shareImage(); } }); // Set the banner link TextView textview = (TextView) findViewById(R.id.banner_listing_link); textview.setTextColor(getResources().getColor(R.color.tvdb_green)); textview.setVisibility(View.VISIBLE); textview.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(getApplicationContext(), BannerListing.class); i.putExtra("seriesId", seriesId); i.putExtra("seriesName", seriesName); startActivity(i); } }); // Set air info textview = (TextView) findViewById(R.id.airs_header); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.last_episode); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.next_episode); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.series_air_info); StringBuffer sb = new StringBuffer(); sb.append(seriesInfo.getAirDay()); if (!seriesInfo.getAirTime().equals("")) sb.append(" at " + seriesInfo.getAirTime()); if (!seriesInfo.getNetwork().equals("")) sb.append(" on " + seriesInfo.getNetwork()); textview.setText(sb.toString()); textview.setVisibility(View.VISIBLE); // Set actors textview = (TextView) findViewById(R.id.starring); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.series_actors); textview.setVisibility(View.VISIBLE); SpannableStringBuilder text = tagsBuilder(seriesInfo.getActors(), "|"); textview.setText(text, BufferType.SPANNABLE); textview.setMovementMethod(LinkMovementMethod.getInstance()); // Set rating textview = (TextView) findViewById(R.id.rating_header); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.rating); textview.setText(seriesInfo.getRating() + " / 10"); textview.setVisibility(View.VISIBLE); // Set genre textview = (TextView) findViewById(R.id.genre_header); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.genre); textview.setText(StringUtil.commafy(seriesInfo.getGenre())); textview.setVisibility(View.VISIBLE); // Set runtime textview = (TextView) findViewById(R.id.runtime_header); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.runtime); textview.setText(seriesInfo.getRuntime() + " minutes"); textview.setVisibility(View.VISIBLE); // Set overview textview = (TextView) findViewById(R.id.overview_header); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.overview); textview.setText(seriesInfo.getOverview()); textview.setVisibility(View.VISIBLE); // Show Seasons header textview = (TextView) findViewById(R.id.seasons_header); textview.setVisibility(View.VISIBLE); // IMDB Link textview = (TextView) findViewById(R.id.imdb_link); textview.setVisibility(View.VISIBLE); final String imdbId = seriesInfo.getIMDB(); SpannableStringBuilder ssb = new SpannableStringBuilder(getResources().getString(R.string.imdb)); ssb.setSpan(new NonUnderlinedClickableSpan(getResources().getString(R.string.imdb)) { @Override public void onClick(View v) { Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.imdb.com/title/" + imdbId)); startActivity(myIntent); } }, 0, ssb.length(), 0); ssb.setSpan(new TextAppearanceSpan(this, R.style.episode_link), 0, ssb.length(), 0); // Set the style of the text textview.setText(ssb, BufferType.SPANNABLE); textview.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:org.catrobat.catroid.ui.MainMenuActivity.java
private void setMainMenuButtonContinueText() { Button mainMenuButtonContinue = (Button) this.findViewById(R.id.main_menu_button_continue); TextAppearanceSpan textAppearanceSpan = new TextAppearanceSpan(this, R.style.MainMenuButtonTextSecondLine); SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(); String mainMenuContinue = this.getString(R.string.main_menu_continue); spannableStringBuilder.append(mainMenuContinue); spannableStringBuilder.append("\n"); spannableStringBuilder.append(Utils.getCurrentProjectName(this)); spannableStringBuilder.setSpan(textAppearanceSpan, mainMenuContinue.length() + 1, spannableStringBuilder.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); mainMenuButtonContinue.setText(spannableStringBuilder); }
From source file:com.battlelancer.seriesguide.ui.EpisodeDetailsFragment.java
private void populateEpisodeData(Cursor cursor) { if (cursor == null || !cursor.moveToFirst()) { // no data to display if (mEpisodeContainer != null) { mEpisodeContainer.setVisibility(View.GONE); }//from ww w . j a va2s.co m return; } mShowTvdbId = cursor.getInt(DetailsQuery.REF_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 mEpisodeTitle = cursor.getString(DetailsQuery.TITLE); mTitle.setText(mEpisodeTitle); mDescription.setText(cursor.getString(DetailsQuery.OVERVIEW)); // show title mShowTitle = cursor.getString(DetailsQuery.SHOW_TITLE); // release time and day SpannableStringBuilder timeAndNumbersText = new SpannableStringBuilder(); if (mEpisodeReleaseTime != -1) { Date actualRelease = TimeTools.getEpisodeReleaseTime(getActivity(), mEpisodeReleaseTime); mReleaseDay.setText(TimeTools.formatToDate(getActivity(), actualRelease)); // "in 15 mins (Fri)" timeAndNumbersText.append(getString(R.string.release_date_and_day, TimeTools.formatToRelativeLocalReleaseTime(getActivity(), actualRelease), TimeTools.formatToLocalReleaseDay(actualRelease)).toUpperCase(Locale.getDefault())); timeAndNumbersText.append(" "); } else { mReleaseDay.setText(R.string.unknown); } // absolute number (e.g. relevant for Anime): "ABSOLUTE 142" int numberStartIndex = timeAndNumbersText.length(); int absoluteNumber = cursor.getInt(DetailsQuery.ABSOLUTE_NUMBER); 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, Utils.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.GUESTSTARS))); // DVD episode number Utils.setLabelValueOrHide(mLabelDvd, mDvd, cursor.getDouble(DetailsQuery.DVDNUMBER)); // directors Utils.setValueOrPlaceholder(mDirectors, Utils.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.DIRECTORS))); // writers Utils.setValueOrPlaceholder(mWriters, Utils.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.WRITERS))); // last TVDb edit date long lastEditSeconds = cursor.getLong(DetailsQuery.LASTEDIT); 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) { rateOnTrakt(); } }); mRatingsContainer.setFocusable(true); CheatSheet.setup(mRatingsContainer, R.string.action_rate); // TVDb rating String tvdbRating = cursor.getString(DetailsQuery.RATING); if (!TextUtils.isEmpty(tvdbRating)) { mTvdbRating.setText(tvdbRating); } // trakt ratings loadTraktRatings(true); // episode image final String imagePath = cursor.getString(DetailsQuery.IMAGE); mImageContainer.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent fullscreen = new Intent(getActivity(), FullscreenImageActivity.class); fullscreen.putExtra(FullscreenImageActivity.InitBundle.IMAGE_PATH, imagePath); ActivityCompat.startActivity(getActivity(), fullscreen, ActivityOptionsCompat .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle()); } }); loadImage(imagePath); // check in button final int episodeTvdbId = cursor.getInt(DetailsQuery._ID); mCheckinButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // display a check-in dialog CheckInDialogFragment f = CheckInDialogFragment.newInstance(getActivity(), episodeTvdbId); f.show(getFragmentManager(), "checkin-dialog"); fireTrackerEvent("Check-In"); } }); CheatSheet.setup(mCheckinButton); // watched button mEpisodeFlag = cursor.getInt(DetailsQuery.WATCHED); boolean isWatched = EpisodeTools.isWatched(mEpisodeFlag); Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mWatchedButton, 0, isWatched ? Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatched) : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatch), 0, 0); mWatchedButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable button, will be re-enabled on data reload once action completes v.setEnabled(false); onToggleWatched(); fireTrackerEvent("Toggle watched"); } }); mWatchedButton.setEnabled(true); mWatchedButton.setText(isWatched ? R.string.action_unwatched : R.string.action_watched); CheatSheet.setup(mWatchedButton, isWatched ? R.string.action_unwatched : R.string.action_watched); // collected button mCollected = cursor.getInt(DetailsQuery.COLLECTED) == 1; Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mCollectedButton, 0, mCollected ? R.drawable.ic_collected : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableCollect), 0, 0); mCollectedButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable button, will be re-enabled on data reload once action completes v.setEnabled(false); onToggleCollected(); fireTrackerEvent("Toggle collected"); } }); mCollectedButton.setEnabled(true); mCollectedButton.setText(mCollected ? R.string.action_collection_remove : R.string.action_collection_add); CheatSheet.setup(mCollectedButton, 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 mSkipButton.setVisibility(View.INVISIBLE); } else { mSkipButton.setVisibility(View.VISIBLE); Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mSkipButton, 0, isSkipped ? R.drawable.ic_skipped : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableSkip), 0, 0); mSkipButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable button, will be re-enabled on data reload once action completes v.setEnabled(false); onToggleSkipped(); fireTrackerEvent("Toggle skipped"); } }); mSkipButton.setText(isSkipped ? R.string.action_dont_skip : R.string.action_skip); CheatSheet.setup(mSkipButton, isSkipped ? R.string.action_dont_skip : R.string.action_skip); } mSkipButton.setEnabled(true); // service buttons ServiceUtils.setUpTraktButton(mShowTvdbId, mSeasonNumber, mEpisodeNumber, mTraktButton, 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, getActivity()); // TVDb final int seasonTvdbId = cursor.getInt(DetailsQuery.REF_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(), TraktShoutsActivity.class); intent.putExtras(TraktShoutsActivity.createInitBundleEpisode(mShowTvdbId, mSeasonNumber, mEpisodeNumber, mEpisodeTitle)); ActivityCompat.startActivity(getActivity(), intent, ActivityOptionsCompat .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle()); fireTrackerEvent("Comments"); } }); mEpisodeContainer.setVisibility(View.VISIBLE); }
From source file:com.heath_bar.tvdb.SeriesOverview.java
private SpannableStringBuilder tagsBuilder(String text, String delim) { SpannableStringBuilder builtTags = new SpannableStringBuilder(); int start = 0; int end = 0;/* ww w . j av a 2 s. c o m*/ // if no text, break early if (text.length() == 0) return builtTags; // If the string starts with delim, remove the first delim if (text.substring(0, 1).equals(delim)) text = text.substring(1); do { start = 0; end = text.indexOf(delim, 0); try { if (start < end) { final Context ctx = getApplicationContext(); String targetString = text.substring(start, end); SpannableStringBuilder ssb = new SpannableStringBuilder(targetString); ssb.setSpan(new NonUnderlinedClickableSpan(targetString) { @Override public void onClick(View v) { Intent myIntent = new Intent(ctx, ActorDetails.class); myIntent.putExtra("ActorName", tag); myIntent.putExtra("seriesId", seriesId); myIntent.putExtra("seriesName", seriesInfo.getName()); startActivityForResult(myIntent, 0); } }, start, end, 0); ssb.setSpan(new TextAppearanceSpan(this, R.style.episode_link), 0, ssb.length(), 0); // Set the style of the text //ssb.setSpan(new AbsoluteSizeSpan((int)textSize, true), 0, ssb.length(), 0); // Override the text size with the user's preference builtTags.append(ssb); if (text.substring(end + 1).indexOf(delim) >= 0) builtTags.append(", "); text = text.substring(end + 1); } } catch (IndexOutOfBoundsException e) { } } while (start < end); return builtTags; }
From source file:com.andrewshu.android.reddit.threads.ThreadsListActivity.java
public static void fillThreadsListItemView(int position, View view, ThingInfo item, ListActivity activity, HttpClient client, RedditSettings settings, ThumbnailOnClickListenerFactory thumbnailOnClickListenerFactory) { Resources res = activity.getResources(); TextView titleView = (TextView) view.findViewById(R.id.title); TextView votesView = (TextView) view.findViewById(R.id.votes); TextView numCommentsSubredditView = (TextView) view.findViewById(R.id.numCommentsSubreddit); TextView nsfwView = (TextView) view.findViewById(R.id.nsfw); // TextView submissionTimeView = (TextView) view.findViewById(R.id.submissionTime); ImageView voteUpView = (ImageView) view.findViewById(R.id.vote_up_image); ImageView voteDownView = (ImageView) view.findViewById(R.id.vote_down_image); View thumbnailContainer = view.findViewById(R.id.thumbnail_view); FrameLayout thumbnailFrame = (FrameLayout) view.findViewById(R.id.thumbnail_frame); ImageView thumbnailImageView = (ImageView) view.findViewById(R.id.thumbnail); ProgressBar indeterminateProgressBar = (ProgressBar) view.findViewById(R.id.indeterminate_progress); // Set the title and domain using a SpannableStringBuilder SpannableStringBuilder builder = new SpannableStringBuilder(); String title = item.getTitle(); if (title == null) title = ""; SpannableString titleSS = new SpannableString(title); int titleLen = title.length(); titleSS.setSpan(// ww w . ja v a 2 s.c om new TextAppearanceSpan(activity, Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Large)), 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); String domain = item.getDomain(); if (domain == null) domain = ""; int domainLen = domain.length(); SpannableString domainSS = new SpannableString("(" + item.getDomain() + ")"); domainSS.setSpan( new TextAppearanceSpan(activity, Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Small)), 0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); if (Util.isLightTheme(settings.getTheme())) { if (item.isClicked()) { ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.purple)); titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else { ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.blue)); titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_50)), 0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (item.isClicked()) { ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.gray_50)); titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_75)), 0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } builder.append(titleSS).append(" ").append(domainSS); titleView.setText(builder); votesView.setText("" + item.getScore()); numCommentsSubredditView.setText(Util.showNumComments(item.getNum_comments()) + " " + item.getSubreddit()); if (item.isOver_18()) { nsfwView.setVisibility(View.VISIBLE); } else { nsfwView.setVisibility(View.GONE); } // Set the up and down arrow colors based on whether user likes if (settings.isLoggedIn()) { if (item.getLikes() == null) { voteUpView.setImageResource(R.drawable.vote_up_gray); voteDownView.setImageResource(R.drawable.vote_down_gray); votesView.setTextColor(res.getColor(R.color.gray_75)); } else if (item.getLikes() == true) { voteUpView.setImageResource(R.drawable.vote_up_red); voteDownView.setImageResource(R.drawable.vote_down_gray); votesView.setTextColor(res.getColor(R.color.arrow_red)); } else { voteUpView.setImageResource(R.drawable.vote_up_gray); voteDownView.setImageResource(R.drawable.vote_down_blue); votesView.setTextColor(res.getColor(R.color.arrow_blue)); } } else { voteUpView.setImageResource(R.drawable.vote_up_gray); voteDownView.setImageResource(R.drawable.vote_down_gray); votesView.setTextColor(res.getColor(R.color.gray_75)); } // Thumbnails open links if (thumbnailContainer != null) { if (Common.shouldLoadThumbnails(activity, settings)) { thumbnailContainer.setVisibility(View.VISIBLE); if (item.getUrl() != null) { OnClickListener thumbnailOnClickListener = thumbnailOnClickListenerFactory .getThumbnailOnClickListener(item, activity); if (thumbnailOnClickListener != null) { thumbnailFrame.setOnClickListener(thumbnailOnClickListener); } } // Show thumbnail based on ThingInfo if ("default".equals(item.getThumbnail()) || "self".equals(item.getThumbnail()) || StringUtils.isEmpty(item.getThumbnail())) { indeterminateProgressBar.setVisibility(View.GONE); thumbnailImageView.setVisibility(View.VISIBLE); thumbnailImageView.setImageResource(R.drawable.go_arrow); } else { indeterminateProgressBar.setVisibility(View.GONE); thumbnailImageView.setVisibility(View.VISIBLE); if (item.getThumbnailBitmap() != null) { thumbnailImageView.setImageBitmap(item.getThumbnailBitmap()); } else { thumbnailImageView.setImageBitmap(null); new ShowThumbnailsTask(activity, client, R.drawable.go_arrow) .execute(new ThumbnailLoadAction(item, thumbnailImageView, position)); } } // Set thumbnail background based on current theme if (Util.isLightTheme(settings.getTheme())) thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_light); else thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_dark); } else { // if thumbnails disabled, hide thumbnail icon thumbnailContainer.setVisibility(View.GONE); } } }
From source file:com.android.mail.browse.ConversationItemView.java
private static synchronized void getItemViewResources(Context context) { if (sConfigurationChangedReceiver == null) { sConfigurationChangedReceiver = new BroadcastReceiver() { @Override//w ww . java2s . com public void onReceive(Context context, Intent intent) { STAR_OFF = null; getItemViewResources(context); } }; context.registerReceiver(sConfigurationChangedReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); } if (STAR_OFF == null) { final Resources res = context.getResources(); // Initialize static bitmaps. STAR_OFF = BitmapFactory.decodeResource(res, R.drawable.ic_star_outline_20dp); STAR_ON = BitmapFactory.decodeResource(res, R.drawable.ic_star_20dp); ATTACHMENT = BitmapFactory.decodeResource(res, R.drawable.ic_attach_file_18dp); ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double); TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single); IMPORTANT_ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double_important_unread); IMPORTANT_TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single_important_unread); IMPORTANT = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_none_important_unread); STATE_REPLIED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_holo_light); STATE_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_forward_holo_light); STATE_REPLIED_AND_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_forward_holo_light); STATE_CALENDAR_INVITE = BitmapFactory.decodeResource(res, R.drawable.ic_badge_invite_holo_light); FOCUSED_CONVERSATION_HIGHLIGHT = res.getDrawable(R.drawable.visible_conversation_highlight); // Initialize colors. sActivatedTextSpan = CharacterStyle .wrap(new ForegroundColorSpan(res.getColor(R.color.senders_text_color))); sSendersTextColor = res.getColor(R.color.senders_text_color); sSubjectTextUnreadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceUnreadStyle); sSubjectTextReadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceReadStyle); sBadgeTextSpan = new TextAppearanceSpan(context, R.style.BadgeTextStyle); sBadgeBackgroundSpan = new BackgroundColorSpan(res.getColor(R.color.badge_background_color)); sDateTextColorRead = res.getColor(R.color.date_text_color_read); sDateTextColorUnread = res.getColor(R.color.date_text_color_unread); sStarTouchSlop = res.getDimensionPixelSize(R.dimen.star_touch_slop); sSenderImageTouchSlop = res.getDimensionPixelSize(R.dimen.sender_image_touch_slop); sShrinkAnimationDuration = res.getInteger(R.integer.shrink_animation_duration); sSlideAnimationDuration = res.getInteger(R.integer.slide_animation_duration); // Initialize static color. sSendersSplitToken = res.getString(R.string.senders_split_token); sElidedPaddingToken = res.getString(R.string.elided_padding_token); sScrollSlop = res.getInteger(R.integer.swipeScrollSlop); sFoldersMaxCount = res.getInteger(R.integer.conversation_list_max_folder_count); sCabAnimationDuration = res.getInteger(R.integer.conv_item_view_cab_anim_duration); sBadgePaddingExtraWidth = res.getDimensionPixelSize(R.dimen.badge_padding_extra_width); sBadgeRoundedCornerRadius = res.getDimensionPixelSize(R.dimen.badge_rounded_corner_radius); sDividerPaint.setColor(res.getColor(R.color.divider_color)); sDividerHeight = res.getDimensionPixelSize(R.dimen.divider_height); } }
From source file:com.heath_bar.tvdb.SeriesOverview.java
/** Populate the GUI with the episode information */ private void PopulateStuffPartTwo() { // Populate the next/last episodes TvEpisode last = episodeList.getLastAired(); TvEpisode next = episodeList.getNextAired(); SpannableString text = null;/* ww w . jav a2s .c o m*/ TextView richTextView = (TextView) findViewById(R.id.last_episode); if (last == null) { text = new SpannableString("Last Episode: unknown"); } else { text = new SpannableString( "Last Episode: " + last.getName() + " (" + DateUtil.toString(last.getAirDate()) + ")"); NonUnderlinedClickableSpan clickableSpan = new NonUnderlinedClickableSpan() { @Override public void onClick(View view) { episodeListener.onClick(view); } }; int start = 14; int end = start + last.getName().length(); text.setSpan(clickableSpan, start, end, 0); text.setSpan(new TextAppearanceSpan(this, R.style.episode_link), start, end, 0); text.setSpan(new AbsoluteSizeSpan((int) textSize, true), 0, text.length(), 0); richTextView.setId(last.getId()); richTextView.setMovementMethod(LinkMovementMethod.getInstance()); } richTextView.setText(text, BufferType.SPANNABLE); text = null; richTextView = (TextView) findViewById(R.id.next_episode); if (seriesInfo != null && seriesInfo.getStatus() != null && !seriesInfo.getStatus().equals("Ended")) { if (next == null) { text = new SpannableString("Next Episode: unknown"); } else { text = new SpannableString( "Next Episode: " + next.getName() + " (" + DateUtil.toString(next.getAirDate()) + ")"); NonUnderlinedClickableSpan clickableSpan = new NonUnderlinedClickableSpan() { @Override public void onClick(View view) { episodeListener.onClick(view); } }; int start = 14; int end = start + next.getName().length(); text.setSpan(clickableSpan, start, end, 0); text.setSpan(new TextAppearanceSpan(this, R.style.episode_link), start, end, 0); text.setSpan(new AbsoluteSizeSpan((int) textSize, true), 0, text.length(), 0); richTextView.setId(next.getId()); richTextView.setMovementMethod(LinkMovementMethod.getInstance()); } richTextView.setText(text, BufferType.SPANNABLE); } }
From source file:in.shick.diode.threads.ThreadsListActivity.java
public static void fillThreadsListItemView(int position, View view, ThingInfo item, ListActivity activity, HttpClient client, RedditSettings settings, ThumbnailOnClickListenerFactory thumbnailOnClickListenerFactory) { Resources res = activity.getResources(); ViewHolder vh;//from ww w. j a va2 s. c om if (view.getTag() == null) { vh = new ViewHolder(); vh.titleView = (TextView) view.findViewById(R.id.title); vh.votesView = (TextView) view.findViewById(R.id.votes); vh.numCommentsSubredditView = (TextView) view.findViewById(R.id.numCommentsSubreddit); vh.nsfwView = (TextView) view.findViewById(R.id.nsfw); vh.voteUpView = (ImageView) view.findViewById(R.id.vote_up_image); vh.voteDownView = (ImageView) view.findViewById(R.id.vote_down_image); vh.thumbnailContainer = view.findViewById(R.id.thumbnail_view); vh.thumbnailFrame = (FrameLayout) view.findViewById(R.id.thumbnail_frame); vh.thumbnailImageView = (ImageView) view.findViewById(R.id.thumbnail); vh.indeterminateProgressBar = (ProgressBar) view.findViewById(R.id.indeterminate_progress); view.setTag(vh); } else { vh = (ViewHolder) view.getTag(); } // Need to store the Thing's id in the thumbnail image so that the thumbnail loader task // knows that the row is still displaying the requested thumbnail. vh.thumbnailImageView.setTag(item.getId()); // Set the title and domain using a SpannableStringBuilder SpannableStringBuilder builder = new SpannableStringBuilder(); String title = item.getTitle(); if (title == null) title = ""; SpannableString titleSS = new SpannableString(title); int titleLen = title.length(); titleSS.setSpan( new TextAppearanceSpan(activity, Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Large)), 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); String domain = item.getDomain(); if (domain == null) domain = ""; String flair = item.getLink_flair_text(); if (flair == null) { flair = ""; } else { flair = "[" + flair + "] "; } int domainLen = domain.length() + flair.length(); SpannableString domainSS = new SpannableString(flair + "(" + item.getDomain() + ")"); domainSS.setSpan( new TextAppearanceSpan(activity, Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Small)), 0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); if (Util.isLightTheme(settings.getTheme())) { if (item.isClicked()) { ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.purple)); titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else { ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.blue)); titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_50)), 0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (item.isClicked()) { ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.gray_50)); titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_75)), 0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } builder.append(titleSS).append(" ").append(domainSS); vh.titleView.setText(builder); vh.votesView.setText(String.format(Locale.US, "%d", item.getScore())); // Lock icon emoji String preText = item.isLocked() ? "\uD83D\uDD12 " : ""; vh.numCommentsSubredditView .setText(preText + Util.showNumComments(item.getNum_comments()) + " " + item.getSubreddit()); vh.nsfwView.setVisibility(item.isOver_18() ? View.VISIBLE : View.GONE); // Set the up and down arrow colors based on whether user likes if (settings.isLoggedIn()) { if (item.getLikes() == null) { vh.voteUpView.setImageResource(R.drawable.vote_up_gray); vh.voteDownView.setImageResource(R.drawable.vote_down_gray); vh.votesView.setTextColor(res.getColor(R.color.gray_75)); } else if (item.getLikes()) { vh.voteUpView.setImageResource(R.drawable.vote_up_red); vh.voteDownView.setImageResource(R.drawable.vote_down_gray); vh.votesView.setTextColor(res.getColor(R.color.arrow_red)); } else { vh.voteUpView.setImageResource(R.drawable.vote_up_gray); vh.voteDownView.setImageResource(R.drawable.vote_down_blue); vh.votesView.setTextColor(res.getColor(R.color.arrow_blue)); } } else { vh.voteUpView.setImageResource(R.drawable.vote_up_gray); vh.voteDownView.setImageResource(R.drawable.vote_down_gray); vh.votesView.setTextColor(res.getColor(R.color.gray_75)); } // Thumbnails open links if (vh.thumbnailContainer != null) { if (Common.shouldLoadThumbnails(activity, settings)) { vh.thumbnailContainer.setVisibility(View.VISIBLE); if (item.getUrl() != null) { OnClickListener thumbnailOnClickListener = thumbnailOnClickListenerFactory .getThumbnailOnClickListener(item, activity); if (thumbnailOnClickListener != null) { vh.thumbnailFrame.setOnClickListener(thumbnailOnClickListener); } } // Show thumbnail based on ThingInfo if (Constants.NSFW_STRING.equalsIgnoreCase(item.getThumbnail()) || Constants.DEFAULT_STRING.equals(item.getThumbnail()) || Constants.SUBMIT_KIND_SELF.equals(item.getThumbnail()) || StringUtils.isEmpty(item.getThumbnail())) { vh.indeterminateProgressBar.setVisibility(View.GONE); vh.thumbnailImageView.setVisibility(View.VISIBLE); vh.thumbnailImageView.setImageResource(R.drawable.go_arrow); } else { if (item.getThumbnailBitmap() != null) { vh.indeterminateProgressBar.setVisibility(View.GONE); vh.thumbnailImageView.setVisibility(View.VISIBLE); vh.thumbnailImageView.setImageBitmap(item.getThumbnailBitmap()); } else { vh.indeterminateProgressBar.setVisibility(View.VISIBLE); vh.thumbnailImageView.setVisibility(View.GONE); vh.thumbnailImageView.setImageBitmap(null); new ShowThumbnailsTask(activity, client, R.drawable.go_arrow) .execute(new ThumbnailLoadAction(item, vh.thumbnailImageView, position, vh.indeterminateProgressBar)); } } // Set thumbnail background based on current theme if (Util.isLightTheme(settings.getTheme())) vh.thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_light); else vh.thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_dark); } else { // if thumbnails disabled, hide thumbnail icon vh.thumbnailContainer.setVisibility(View.GONE); } } }
From source file:io.plaidapp.ui.DesignerNewsStory.java
private void bindDescription() { final TextView storyComment = (TextView) header.findViewById(R.id.story_comment); if (!TextUtils.isEmpty(story.comment)) { HtmlUtils.setTextWithNiceLinks(storyComment, markdown.markdownToSpannable(story.comment, storyComment, new Bypass.LoadImageCallback() { @Override//from w w w.j a va 2s . co m public void loadImage(String src, ImageLoadingSpan loadingSpan) { Glide.with(DesignerNewsStory.this).load(src).asBitmap() .diskCacheStrategy(DiskCacheStrategy.ALL) .into(new ImageSpanTarget(storyComment, loadingSpan)); } })); } else { storyComment.setVisibility(View.GONE); } upvoteStory = (Button) header.findViewById(R.id.story_vote_action); upvoteStory.setText(getResources().getQuantityString(R.plurals.upvotes, story.vote_count, NumberFormat.getInstance().format(story.vote_count))); upvoteStory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { upvoteStory(); } }); Button share = (Button) header.findViewById(R.id.story_share_action); share.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(ShareCompat.IntentBuilder.from(DesignerNewsStory.this).setText(story.url) .setType("text/plain").setSubject(story.title).getIntent()); } }); TextView storyPosterTime = (TextView) header.findViewById(R.id.story_poster_time); SpannableString poster = new SpannableString("" + story.user_display_name); poster.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance_CommentAuthor), 0, poster.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); CharSequence job = !TextUtils.isEmpty(story.user_job) ? "\n" + story.user_job : ""; CharSequence timeAgo = DateUtils.getRelativeTimeSpanString(story.created_at.getTime(), System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS); storyPosterTime.setText(TextUtils.concat(poster, job, "\n", timeAgo)); ImageView avatar = (ImageView) header.findViewById(R.id.story_poster_avatar); if (!TextUtils.isEmpty(story.user_portrait_url)) { Glide.with(this).load(story.user_portrait_url).placeholder(R.drawable.avatar_placeholder) .transform(circleTransform).into(avatar); } else { avatar.setVisibility(View.GONE); } }
From source file:io.plaidapp.ui.DesignerNewsStory.java
private void bindDescription() { final TextView storyComment = (TextView) header.findViewById(R.id.story_comment); if (!TextUtils.isEmpty(story.comment)) { HtmlUtils.parseMarkdownAndSetText(storyComment, story.comment, markdown, new Bypass.LoadImageCallback() { @Override//w ww .j ava 2 s .co m public void loadImage(String src, ImageLoadingSpan loadingSpan) { Glide.with(DesignerNewsStory.this).load(src).asBitmap() .diskCacheStrategy(DiskCacheStrategy.ALL) .into(new ImageSpanTarget(storyComment, loadingSpan)); } }); } else { storyComment.setVisibility(View.GONE); } upvoteStory = (TextView) header.findViewById(R.id.story_vote_action); upvoteStory.setText(getResources().getQuantityString(R.plurals.upvotes, story.vote_count, NumberFormat.getInstance().format(story.vote_count))); upvoteStory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { upvoteStory(); } }); final TextView share = (TextView) header.findViewById(R.id.story_share_action); share.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((AnimatedVectorDrawable) share.getCompoundDrawables()[1]).start(); startActivity(ShareCompat.IntentBuilder.from(DesignerNewsStory.this).setText(story.url) .setType("text/plain").setSubject(story.title).getIntent()); } }); TextView storyPosterTime = (TextView) header.findViewById(R.id.story_poster_time); SpannableString poster = new SpannableString(story.user_display_name.toLowerCase()); poster.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance_CommentAuthor), 0, poster.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); CharSequence job = !TextUtils.isEmpty(story.user_job) ? "\n" + story.user_job.toLowerCase() : ""; CharSequence timeAgo = DateUtils.getRelativeTimeSpanString(story.created_at.getTime(), System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS).toString().toLowerCase(); storyPosterTime.setText(TextUtils.concat(poster, job, "\n", timeAgo)); ImageView avatar = (ImageView) header.findViewById(R.id.story_poster_avatar); if (!TextUtils.isEmpty(story.user_portrait_url)) { Glide.with(this).load(story.user_portrait_url).placeholder(R.drawable.avatar_placeholder) .transform(circleTransform).into(avatar); } else { avatar.setVisibility(View.GONE); } }