Example usage for android.widget TextView setPaintFlags

List of usage examples for android.widget TextView setPaintFlags

Introduction

In this page you can find the example usage for android.widget TextView setPaintFlags.

Prototype

@android.view.RemotableViewMethod
public void setPaintFlags(int flags) 

Source Link

Document

Sets flags on the Paint being used to display the text and reflows the text if they are different from the old flags.

Usage

From source file:com.aniruddhc.acemusic.player.LauncherActivity.LauncherActivity.java

public void showTrialDialog(final boolean expired, int numDaysRemaining) {

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setTitle(R.string.app_name);
    builder.setCancelable(false);/*  w  w w.j av  a 2  s.  c o  m*/

    View view = this.getLayoutInflater().inflate(R.layout.trial_expiry_dialog, null);
    TextView trialExpiredText = (TextView) view.findViewById(R.id.trial_message);
    TextView trialDaysRemaining = (TextView) view.findViewById(R.id.trial_days_remaining);
    TextView trialDaysCaps = (TextView) view.findViewById(R.id.days_caps);

    trialExpiredText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    trialExpiredText
            .setPaintFlags(trialExpiredText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    trialDaysRemaining.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));

    trialDaysCaps.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    trialDaysCaps
            .setPaintFlags(trialDaysCaps.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    if (expired) {
        trialDaysRemaining.setText(R.string.expired);
        trialExpiredText.setText(R.string.trial_expired);
        trialDaysRemaining.setTextColor(0xFFFF8800);
        trialDaysCaps.setVisibility(View.GONE);
        trialDaysRemaining.setTextSize(36);
        trialDaysRemaining.setPaintFlags(
                trialDaysRemaining.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    } else {
        trialExpiredText.setText(R.string.trial_running);
        trialDaysRemaining.setText("" + numDaysRemaining);
        trialDaysCaps.setVisibility(View.VISIBLE);
        trialDaysRemaining.setTextColor(0xFF0099CC);
        trialDaysRemaining.setPaintFlags(trialDaysRemaining.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
                | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
    }

    builder.setView(view);
    builder.setPositiveButton(R.string.upgrade, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            showUpgradeFragmentWithPromo();

        }

    });

    builder.setNegativeButton(R.string.later, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (expired) {
                finish();
            } else {
                launchMainActivity();
            }

        }

    });

    builder.create().show();
}

From source file:com.hypodiabetic.happ.MainActivity.java

public void displayCurrentInfo() {
    final TextView currentBgValueText = (TextView) findViewById(R.id.currentBgValueRealTime);
    final TextView notificationText = (TextView) findViewById(R.id.notices);
    final TextView deltaText = (TextView) findViewById(R.id.bgDelta);
    if ((currentBgValueText.getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) > 0) {
        currentBgValueText.setPaintFlags(currentBgValueText.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
    }//from   www.jav  a  2s .  c o  m
    Bg lastBgreading = Bg.last();

    if (lastBgreading != null) {
        notificationText.setText(lastBgreading.readingAge());
        String bgDelta = tools.unitizedBG(lastBgreading.bgdelta, MainApp.instance().getApplicationContext());
        if (lastBgreading.bgdelta >= 0)
            bgDelta = "+" + bgDelta;
        deltaText.setText(bgDelta);
        currentBgValueText.setText(extendedGraphBuilder.unitized_string(lastBgreading.sgv_double()) + " "
                + lastBgreading.slopeArrow());

        if ((new Date().getTime()) - (60000 * 16) - lastBgreading.datetime > 0) {
            notificationText.setTextColor(Color.parseColor("#C30909"));
            currentBgValueText.setPaintFlags(currentBgValueText.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            notificationText.setTextColor(Color.WHITE);
        }
        double estimate = lastBgreading.sgv_double();
        if (extendedGraphBuilder.unitized(estimate) <= extendedGraphBuilder.lowMark) {
            currentBgValueText.setTextColor(Color.parseColor("#C30909"));
        } else if (extendedGraphBuilder.unitized(estimate) >= extendedGraphBuilder.highMark) {
            currentBgValueText.setTextColor(Color.parseColor("#FFBB33"));
        } else {
            currentBgValueText.setTextColor(Color.WHITE);
        }
    }

    //Stats UI update
    updateStats(null);

    //OpenAPS UI update
    updateOpenAPSDetails(null);

    //Temp Basal running update
    updateRunningTemp();
}

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 ww.ja  va2 s .co 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  w  ww.j  a  v  a  2 s  . co  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.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;/*from  w  w w . ja va 2  s. c  om*/

                } 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();
        }
    }
}