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 scdl by passy.
the class BuyAdFreeTeaserFragment method onActivityCreated.
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final Spanned html = Html.fromHtml(getActivity().getString(R.string.buy_ad_free_teaser_text));
mTeaserText.setText(html);
mButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
requestPurchase();
}
});
}
use of android.text.Spanned in project material-calendarview by prolificinteractive.
the class DayView method setDayFormatter.
/**
* Set the new label formatter and reformat the current label. This preserves current spans.
*
* @param formatter new label formatter
*/
public void setDayFormatter(DayFormatter formatter) {
this.formatter = formatter == null ? DayFormatter.DEFAULT : formatter;
CharSequence currentLabel = getText();
Object[] spans = null;
if (currentLabel instanceof Spanned) {
spans = ((Spanned) currentLabel).getSpans(0, currentLabel.length(), Object.class);
}
SpannableString newLabel = new SpannableString(getLabel());
if (spans != null) {
for (Object span : spans) {
newLabel.setSpan(span, 0, newLabel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
setText(newLabel);
}
use of android.text.Spanned in project platform_frameworks_base by android.
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 platform_frameworks_base by android.
the class Editor method selectCurrentWord.
/**
* Adjusts selection to the word under last touch offset. Return true if the operation was
* successfully performed.
*/
private boolean selectCurrentWord() {
if (!mTextView.canSelectText()) {
return false;
}
if (needsToSelectAllToSelectWordOrParagraph()) {
return mTextView.selectAllText();
}
long lastTouchOffsets = getLastTouchOffsets();
final int minOffset = TextUtils.unpackRangeStartFromLong(lastTouchOffsets);
final int maxOffset = TextUtils.unpackRangeEndFromLong(lastTouchOffsets);
// Safety check in case standard touch event handling has been bypassed
if (minOffset < 0 || minOffset > mTextView.getText().length())
return false;
if (maxOffset < 0 || maxOffset > mTextView.getText().length())
return false;
int selectionStart, selectionEnd;
// If a URLSpan (web address, email, phone...) is found at that position, select it.
URLSpan[] urlSpans = ((Spanned) mTextView.getText()).getSpans(minOffset, maxOffset, URLSpan.class);
if (urlSpans.length >= 1) {
URLSpan urlSpan = urlSpans[0];
selectionStart = ((Spanned) mTextView.getText()).getSpanStart(urlSpan);
selectionEnd = ((Spanned) mTextView.getText()).getSpanEnd(urlSpan);
} else {
// FIXME - We should check if there's a LocaleSpan in the text, this may be
// something we should try handling or checking for.
final WordIterator wordIterator = getWordIterator();
wordIterator.setCharSequence(mTextView.getText(), minOffset, maxOffset);
selectionStart = wordIterator.getBeginning(minOffset);
selectionEnd = wordIterator.getEnd(maxOffset);
if (selectionStart == BreakIterator.DONE || selectionEnd == BreakIterator.DONE || selectionStart == selectionEnd) {
// Possible when the word iterator does not properly handle the text's language
long range = getCharClusterRange(minOffset);
selectionStart = TextUtils.unpackRangeStartFromLong(range);
selectionEnd = TextUtils.unpackRangeEndFromLong(range);
}
}
Selection.setSelection((Spannable) mTextView.getText(), selectionStart, selectionEnd);
return selectionEnd > selectionStart;
}
Aggregations