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