Search in sources :

Example 31 with Spanned

use of android.text.Spanned in project Jota-Text-Editor-old by jiro-aqua.

the class DrawableMarginSpan method drawLeadingMargin.

public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) {
    int st = ((Spanned) text).getSpanStart(this);
    int ix = (int) x;
    int itop = (int) layout.getLineTop(layout.getLineForOffset(st));
    int dw = mDrawable.getIntrinsicWidth();
    int dh = mDrawable.getIntrinsicHeight();
    if (dir < 0)
        x -= dw;
    // XXX What to do about Paint?
    mDrawable.setBounds(ix, itop, ix + dw, itop + dh);
    mDrawable.draw(c);
}
Also used : Spanned(android.text.Spanned) Paint(android.graphics.Paint)

Example 32 with Spanned

use of android.text.Spanned in project Jota-Text-Editor-old by jiro-aqua.

the class TextView method onSaveInstanceState.

@Override
public Parcelable onSaveInstanceState() {
    Parcelable superState = super.onSaveInstanceState();
    // Save state if we are forced to
    boolean save = mFreezesText;
    int start = 0;
    int end = 0;
    if (mText != null) {
        start = getSelectionStart();
        end = getSelectionEnd();
        if (start >= 0 || end >= 0) {
            // Or save state if there is a selection
            save = true;
        }
    }
    if (save) {
        SavedState ss = new SavedState(superState);
        // XXX Should also save the current scroll position!
        ss.selStart = start;
        ss.selEnd = end;
        if (mText instanceof Spanned) {
            /*
                 * Calling setText() strips off any ChangeWatchers;
                 * strip them now to avoid leaking references.
                 * But do it to a copy so that if there are any
                 * further changes to the text of this view, it
                 * won't get into an inconsistent state.
                 */
            Spannable sp = new SpannableString(mText);
            for (ChangeWatcher cw : sp.getSpans(0, sp.length(), ChangeWatcher.class)) {
                sp.removeSpan(cw);
            }
            ss.text = sp;
        } else {
            ss.text = mText.toString();
        }
        if (isFocused() && start >= 0 && end >= 0) {
            ss.frozenWithFocus = true;
        }
        ss.error = mError;
        // Jota Text Editor
        ss.undoBuffer = mUndoBuffer;
        // Jota Text Editor
        ss.redoBuffer = mRedoBuffer;
        // Jota Text Editor
        ss.imeShown = isImeShown();
        return ss;
    }
    return superState;
}
Also used : SpannableString(android.text.SpannableString) Parcelable(android.os.Parcelable) Spanned(android.text.Spanned) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) Spannable(android.text.Spannable)

Example 33 with Spanned

use of android.text.Spanned in project Jota-Text-Editor-old by jiro-aqua.

the class IconMarginSpan method drawLeadingMargin.

public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) {
    int st = ((Spanned) text).getSpanStart(this);
    int itop = layout.getLineTop(layout.getLineForOffset(st));
    if (dir < 0)
        x -= mBitmap.getWidth();
    c.drawBitmap(mBitmap, x, itop, p);
}
Also used : Spanned(android.text.Spanned) Paint(android.graphics.Paint)

Example 34 with Spanned

use of android.text.Spanned in project Talon-for-Twitter by klinker24.

the class SettingsLinkDrawerClickListener method onItemClick.

@Override
public void onItemClick(AdapterView parent, View view, int position, long id) {
    Intent intent;
    final int mPos = position;
    if (mPos < 2) {
        // one of the settings pages
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                mDrawerLayout.closeDrawer(Gravity.START);
            }
        }, 300);
        viewPager.setCurrentItem(mPos + 7, true);
    } else if (mPos == 2) {
        // changelog
        final ListView list = new ListView(context);
        list.setDividerHeight(0);
        new AsyncTask<Spanned[], Void, Spanned[]>() {

            @Override
            public Spanned[] doInBackground(Spanned[]... params) {
                return XmlChangelogUtils.parse(context);
            }

            @Override
            public void onPostExecute(Spanned[] result) {
                list.setAdapter(new ChangelogAdapter(context, result));
            }
        }.execute();
        new AlertDialog.Builder(context).setTitle(R.string.changelog).setView(list).setPositiveButton(R.string.ok, null).show();
    } else if (mPos == 3) {
        // rate it option
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
                Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
                try {
                    context.startActivity(goToMarket);
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(context, "Couldn't launch the market", Toast.LENGTH_SHORT).show();
                }
            }
        }, 200);
    }
}
Also used : AlertDialog(android.app.AlertDialog) AsyncTask(android.os.AsyncTask) Handler(android.os.Handler) Intent(android.content.Intent) Spanned(android.text.Spanned) Uri(android.net.Uri) ListView(android.widget.ListView) ActivityNotFoundException(android.content.ActivityNotFoundException) ChangelogAdapter(com.klinker.android.twitter.adapters.ChangelogAdapter)

Example 35 with Spanned

use of android.text.Spanned in project AutoLoadListView by ZhaoKaiQiang.

the class JumpingBeans method stopJumping.

/**
     * Stops the jumping animation and frees up the animations.
     */
public void stopJumping() {
    for (JumpingBeansSpan bean : jumpingBeans) {
        if (bean != null) {
            bean.teardown();
        }
    }
    TextView tv = textView.get();
    if (tv != null) {
        CharSequence text = tv.getText();
        if (text instanceof Spanned) {
            CharSequence cleanText = removeJumpingBeansSpans((Spanned) text);
            tv.setText(cleanText);
        }
    }
}
Also used : TextView(android.widget.TextView) Spanned(android.text.Spanned)

Aggregations

Spanned (android.text.Spanned)204 Paint (android.graphics.Paint)81 TextPaint (android.text.TextPaint)63 Spannable (android.text.Spannable)32 SpannableStringBuilder (android.text.SpannableStringBuilder)27 SpannableString (android.text.SpannableString)25 SuggestionSpan (android.text.style.SuggestionSpan)24 Editable (android.text.Editable)22 TextAppearanceSpan (android.text.style.TextAppearanceSpan)15 SpannedString (android.text.SpannedString)14 TypedArray (android.content.res.TypedArray)12 URLSpan (android.text.style.URLSpan)12 View (android.view.View)12 Context (android.content.Context)10 StyleSpan (android.text.style.StyleSpan)9 InputMethodManager (android.view.inputmethod.InputMethodManager)9 TextView (android.widget.TextView)9 Parcelable (android.os.Parcelable)8 WordIterator (android.text.method.WordIterator)7 CharacterStyle (android.text.style.CharacterStyle)7