List of usage examples for android.widget TextView getPaintFlags
public int getPaintFlags()
From source file:com.meiste.greg.ptw.tab.QuestionsAnswers.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { Util.log("QuestionsAnswers: onCreateView"); final String qjson = getArguments().getString(RACE_QUESTIONS); if (qjson == null) { return null; }/*from w w w . j av a2 s . c o m*/ final String ajson = getArguments().getString(RACE_ANSWERS); if (ajson == null) { return null; } final RaceQuestions rq = RaceQuestions.fromJson(qjson); final RaceAnswers ra = RaceAnswers.fromJson(ajson); final Resources res = getActivity().getResources(); final View v = inflater.inflate(R.layout.questions_answered, container, false); final TextView q2 = (TextView) v.findViewById(R.id.question2); q2.setText(getActivity().getString(R.string.questions_2, rq.q2)); final TextView q3 = (TextView) v.findViewById(R.id.question3); q3.setText(getActivity().getString(R.string.questions_3, rq.q3)); final TextView a1 = (TextView) v.findViewById(R.id.answer1); a1.setText(Driver.find(rq.drivers, res, ra.a1).getName()); final TextView a2 = (TextView) v.findViewById(R.id.answer2); a2.setText(rq.a2[ra.a2]); final TextView a3 = (TextView) v.findViewById(R.id.answer3); a3.setText(rq.a3[ra.a3]); final TextView a4 = (TextView) v.findViewById(R.id.answer4); a4.setText(Driver.find(rq.drivers, res, ra.a4).getName()); final TextView a5 = (TextView) v.findViewById(R.id.answer5); a5.setText(res.getStringArray(R.array.num_leaders)[ra.a5]); final String cajson = getArguments().getString(RACE_CORRECT_ANSWERS); if (cajson != null) { Util.log("QuestionsAnswers: Correct answers available"); final RaceAnswers rca = RaceAnswers.fromJson(cajson); // Have to check for null in case there is no correct answer if ((rca.a1 != null) && (rca.a1 >= 0)) { if (rca.a1 == ra.a1) { a1.setTextColor(res.getColor(R.color.answer_right)); } else { a1.setPaintFlags(a1.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); a1.setTextColor(res.getColor(R.color.answer_wrong)); final TextView c1 = (TextView) v.findViewById(R.id.correct1); c1.setText(Driver.find(rq.drivers, res, rca.a1).getName()); c1.setVisibility(View.VISIBLE); } } if ((rca.a2 != null) && (rca.a2 >= 0)) { if (rca.a2 == ra.a2) { a2.setTextColor(res.getColor(R.color.answer_right)); } else { a2.setPaintFlags(a2.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); a2.setTextColor(res.getColor(R.color.answer_wrong)); final TextView c2 = (TextView) v.findViewById(R.id.correct2); c2.setText(rq.a2[rca.a2]); c2.setVisibility(View.VISIBLE); } } if ((rca.a3 != null) && (rca.a3 >= 0)) { if (rca.a3 == ra.a3) { a3.setTextColor(res.getColor(R.color.answer_right)); } else { a3.setPaintFlags(a3.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); a3.setTextColor(res.getColor(R.color.answer_wrong)); final TextView c3 = (TextView) v.findViewById(R.id.correct3); c3.setText(rq.a3[rca.a3]); c3.setVisibility(View.VISIBLE); } } if ((rca.a4 != null) && (rca.a4 >= 0)) { if (rca.a4 == ra.a4) { a4.setTextColor(res.getColor(R.color.answer_right)); } else { a4.setPaintFlags(a4.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); a4.setTextColor(res.getColor(R.color.answer_wrong)); final TextView c4 = (TextView) v.findViewById(R.id.correct4); c4.setText(Driver.find(rq.drivers, res, rca.a4).getName()); c4.setVisibility(View.VISIBLE); } } if ((rca.a5 != null) && (rca.a5 >= 0)) { if (rca.a5 == ra.a5) { a5.setTextColor(res.getColor(R.color.answer_right)); } else { a5.setPaintFlags(a5.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); a5.setTextColor(res.getColor(R.color.answer_wrong)); final TextView c5 = (TextView) v.findViewById(R.id.correct5); c5.setText(res.getStringArray(R.array.num_leaders)[rca.a5]); c5.setVisibility(View.VISIBLE); } } } return v; }
From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java
@SuppressLint("SetTextI18n") public void update(Lyrics lyrics, View layout, boolean animation) { File musicFile = null;/*from ww w .ja v a 2s . c o m*/ Bitmap cover = null; if (PermissionsChecker.hasPermission(getActivity(), "android.permission.READ_EXTERNAL_STORAGE")) { musicFile = Id3Reader.getFile(getActivity(), lyrics.getOriginalArtist(), lyrics.getOriginalTrack()); cover = Id3Reader.getCover(getActivity(), lyrics.getArtist(), lyrics.getTitle()); } setCoverArt(cover, null); boolean artCellDownload = Integer.valueOf( PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("pref_artworks", "0")) == 0; if (cover == null) new CoverArtLoader().execute(lyrics, this.getActivity(), artCellDownload || OnlineAccessVerifier.isConnectedWifi(getActivity())); getActivity().findViewById(R.id.edit_tags_btn).setEnabled(true); getActivity().findViewById(R.id.edit_tags_btn) .setVisibility(musicFile == null || !musicFile.canWrite() || lyrics.isLRC() || Id3Reader.getLyrics(getActivity(), lyrics.getArtist(), lyrics.getTitle()) == null ? View.GONE : View.VISIBLE); TextSwitcher textSwitcher = ((TextSwitcher) layout.findViewById(R.id.switcher)); LrcView lrcView = (LrcView) layout.findViewById(R.id.lrc_view); View v = getActivity().findViewById(R.id.tracks_msg); if (v != null) ((ViewGroup) v.getParent()).removeView(v); TextView artistTV = (TextView) getActivity().findViewById(R.id.artist); TextView songTV = (TextView) getActivity().findViewById(R.id.song); final TextView id3TV = (TextView) layout.findViewById(R.id.source_tv); TextView writerTV = (TextView) layout.findViewById(R.id.writer_tv); TextView copyrightTV = (TextView) layout.findViewById(R.id.copyright_tv); RelativeLayout bugLayout = (RelativeLayout) layout.findViewById(R.id.error_msg); this.mLyrics = lyrics; if (SDK_INT >= ICE_CREAM_SANDWICH) beamLyrics(lyrics, this.getActivity()); new PresenceChecker().execute(this, new String[] { lyrics.getArtist(), lyrics.getTitle(), lyrics.getOriginalArtist(), lyrics.getOriginalTrack() }); if (lyrics.getArtist() != null) artistTV.setText(lyrics.getArtist()); else artistTV.setText(""); if (lyrics.getTitle() != null) songTV.setText(lyrics.getTitle()); else songTV.setText(""); if (lyrics.getCopyright() != null) { copyrightTV.setText("Copyright: " + lyrics.getCopyright()); copyrightTV.setVisibility(View.VISIBLE); } else { copyrightTV.setText(""); copyrightTV.setVisibility(View.GONE); } if (lyrics.getWriter() != null) { if (lyrics.getWriter().contains(",")) writerTV.setText("Writers:\n" + lyrics.getWriter()); else writerTV.setText("Writer:" + lyrics.getWriter()); writerTV.setVisibility(View.VISIBLE); } else { writerTV.setText(""); writerTV.setVisibility(View.GONE); } if (isActiveFragment) ((RefreshIcon) getActivity().findViewById(R.id.refresh_fab)).show(); EditText newLyrics = (EditText) getActivity().findViewById(R.id.edit_lyrics); if (newLyrics != null) newLyrics.setText(""); if (lyrics.getFlag() == Lyrics.POSITIVE_RESULT) { if (!lyrics.isLRC()) { textSwitcher.setVisibility(View.VISIBLE); lrcView.setVisibility(View.GONE); if (animation) textSwitcher.setText(Html.fromHtml(lyrics.getText())); else textSwitcher.setCurrentText(Html.fromHtml(lyrics.getText())); } else { textSwitcher.setVisibility(View.GONE); lrcView.setVisibility(View.VISIBLE); lrcView.setOriginalLyrics(lyrics); lrcView.setSourceLrc(lyrics.getText()); if (isActiveFragment) ((ControllableAppBarLayout) getActivity().findViewById(R.id.appbar)).expandToolbar(true); updateLRC(); } bugLayout.setVisibility(View.INVISIBLE); id3TV.setMovementMethod(LinkMovementMethod.getInstance()); if ("Storage".equals(lyrics.getSource())) { id3TV.setVisibility(View.VISIBLE); SpannableString text = new SpannableString(getString(R.string.from_id3)); text.setSpan(new UnderlineSpan(), 1, text.length() - 1, 0); id3TV.setText(text); id3TV.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((MainActivity) getActivity()).id3PopUp(id3TV); } }); } else { id3TV.setOnClickListener(null); id3TV.setVisibility(View.GONE); } mScrollView.post(new Runnable() { @Override public void run() { mScrollView.scrollTo(0, 0); //only useful when coming from localLyricsFragment mScrollView.smoothScrollTo(0, 0); } }); } else { textSwitcher.setText(""); textSwitcher.setVisibility(View.INVISIBLE); lrcView.setVisibility(View.INVISIBLE); bugLayout.setVisibility(View.VISIBLE); int message; int whyVisibility; if (lyrics.getFlag() == Lyrics.ERROR || !OnlineAccessVerifier.check(getActivity())) { message = R.string.connection_error; whyVisibility = TextView.GONE; } else { message = R.string.no_results; whyVisibility = TextView.VISIBLE; updateSearchView(false, lyrics.getTitle(), false); } TextView whyTextView = ((TextView) bugLayout.findViewById(R.id.bugtext_why)); ((TextView) bugLayout.findViewById(R.id.bugtext)).setText(message); whyTextView.setVisibility(whyVisibility); whyTextView.setPaintFlags(whyTextView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); id3TV.setVisibility(View.GONE); } stopRefreshAnimation(); getActivity().getIntent().setAction(""); getActivity().invalidateOptionsMenu(); }
From source file:com.shopify.buy.ui.ProductDetailsFragmentView.java
/** * Fills in the views with all the {@link Product} details. *///from www . j a va 2 s. c o m private void updateProductDetails() { Resources res = getResources(); findViewById(R.id.product_details_container).setBackgroundColor(theme.getBackgroundColor(res)); // Product title TextView textViewTitle = (TextView) findViewById(R.id.product_title); textViewTitle.setText(product.getTitle()); textViewTitle.setTextColor(theme.getProductTitleColor(res)); // Product price TextView textViewPrice = (TextView) findViewById(R.id.product_price); String priceWithCurrency = currencyFormat.format(Double.parseDouble(variant.getPrice())); textViewPrice.setText(priceWithCurrency); textViewPrice.setTextColor(theme.getAccentColor()); // Product "compare at" price (appears below the actual price with a strikethrough style) TextView textViewCompareAtPrice = (TextView) findViewById(R.id.product_compare_at_price); if (!variant.isAvailable()) { textViewCompareAtPrice.setVisibility(View.VISIBLE); textViewCompareAtPrice.setText(getResources().getString(R.string.sold_out)); textViewCompareAtPrice.setTextColor(getResources().getColor(R.color.error_background)); textViewCompareAtPrice.setPaintFlags(0); } else if (!TextUtils.isEmpty(variant.getCompareAtPrice())) { textViewCompareAtPrice.setVisibility(View.VISIBLE); String compareAtPriceWithCurrency = currencyFormat .format(Double.parseDouble(variant.getCompareAtPrice())); textViewCompareAtPrice.setText(compareAtPriceWithCurrency); textViewCompareAtPrice.setTextColor(theme.getCompareAtPriceColor(res)); textViewCompareAtPrice .setPaintFlags(textViewCompareAtPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } else { textViewCompareAtPrice.setVisibility(View.GONE); } // Set the correct values on the ProductDetailsVariantOptionViews List<OptionValue> optionValues = variant.getOptionValues(); for (OptionValue optionValue : optionValues) { ProductDetailsVariantOptionView optionView = visibleOptionViews .get(Long.valueOf(optionValue.getOptionId())); if (optionView != null) { optionView.setOptionValue(optionValue); } } // Product description TextView textViewDescription = (TextView) findViewById(R.id.product_description); textViewDescription.setText(Html.fromHtml(product.getBodyHtml()), TextView.BufferType.SPANNABLE); textViewDescription.setTextColor(theme.getProductDescriptionColor(res)); // Make the links clickable in the description // http://stackoverflow.com/questions/2734270/how-do-i-make-links-in-a-textview-clickable textViewDescription.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.forrestguice.suntimeswidget.SuntimesActivity.java
public void highlightTimeField(SolarEvents.SolarEventField highlightField) { int nextCardOffset = 0; int currentCard = this.card_flipper.getDisplayedChild(); for (SolarEvents.SolarEventField field : timeFields.keySet()) { TextView txtField = timeFields.get(field); if (txtField != null) { if (field.equals(highlightField)) { txtField.setTypeface(txtField.getTypeface(), Typeface.BOLD); txtField.setPaintFlags(txtField.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); if (currentCard == 0 && field.tomorrow) { nextCardOffset = 1;/* ww w . j a v a 2 s .co m*/ } else if (currentCard == 1 && !field.tomorrow) { nextCardOffset = -1; } } else { txtField.setTypeface(Typeface.create(txtField.getTypeface(), Typeface.NORMAL), Typeface.NORMAL); txtField.setPaintFlags(txtField.getPaintFlags() & (~Paint.UNDERLINE_TEXT_FLAG)); } } } if (!userSwappedCard) { //Log.d("DEBUG", "Swapping card to show highlighted :: userSwappedCard " + userSwappedCard); if (nextCardOffset > 0) { showNextCard(); } else if (nextCardOffset < 0) { showPreviousCard(); } } }