本文整理汇总了Java中android.text.Selection.removeSelection方法的典型用法代码示例。如果您正苦于以下问题:Java Selection.removeSelection方法的具体用法?Java Selection.removeSelection怎么用?Java Selection.removeSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.Selection
的用法示例。
在下文中一共展示了Selection.removeSelection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleClickableSpan
import android.text.Selection; //导入方法依赖的package包/类
public static boolean handleClickableSpan(View view, Layout layout, Spannable buffer, MotionEvent event) {
int action = event.getAction();
if (action == MotionEvent.ACTION_UP ||
action == MotionEvent.ACTION_DOWN) {
int x = (int) event.getX();
int y = (int) event.getY();
x -= view.getPaddingLeft();
y -= view.getPaddingTop();
x += view.getScrollX();
y += view.getScrollY();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
if (link.length != 0) {
if (action == MotionEvent.ACTION_UP) {
link[0].onClick(view);
} else {
Selection.setSelection(buffer,
buffer.getSpanStart(link[0]),
buffer.getSpanEnd(link[0]));
}
return true;
} else {
Selection.removeSelection(buffer);
}
}
return false;
}
示例2: onTouchEvent
import android.text.Selection; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(TextView textView, Spannable spannable, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
mPressedSpan = getPressedSpan(textView, spannable, event);
if (mPressedSpan != null) {
mPressedSpan.unspoiler();
Selection.setSelection(spannable, spannable.getSpanStart(mPressedSpan),
spannable.getSpanEnd(mPressedSpan));
}
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
SpoilerSpan touchedSpan = getPressedSpan(textView, spannable, event);
if (!Objects.equal(touchedSpan, mPressedSpan)) {
mPressedSpan = null;
Selection.removeSelection(spannable);
}
} else {
mPressedSpan = null;
Selection.removeSelection(spannable);
}
return super.onTouchEvent(textView, spannable, event);
}
示例3: onTouchEvent
import android.text.Selection; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
int action = event.getAction();
if (action == MotionEvent.ACTION_DOWN) {
int x = (int) event.getX();
int y = (int) event.getY();
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
Layout layout = widget.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
if (link.length != 0) {
link[0].onClick(widget);
return true;
} else {
Selection.removeSelection(buffer);
}
}
return super.onTouchEvent(widget, buffer, event);
}
示例4: onTouchEvent
import android.text.Selection; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
pressedSpan = getTouchedSpan(widget, buffer, event);
if (pressedSpan != null) {
pressedSpan.setPressed(true);
Selection.setSelection(buffer, buffer.getSpanStart(pressedSpan), buffer.getSpanEnd(pressedSpan));
}
break;
case MotionEvent.ACTION_MOVE:
TouchableSpan pressedSpan2 = getTouchedSpan(widget, buffer, event);
if (pressedSpan != null && pressedSpan2 != pressedSpan) {
pressedSpan.setPressed(false);
pressedSpan = null;
Selection.removeSelection(buffer);
}
break;
default:
if (pressedSpan != null) {
pressedSpan.setPressed(false);
super.onTouchEvent(widget, buffer, event);
}
pressedSpan = null;
Selection.removeSelection(buffer);
break;
}
return true;
}
示例5: onTouchEvent
import android.text.Selection; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
int action = event.getAction();
if (action == MotionEvent.ACTION_UP ||
action == MotionEvent.ACTION_DOWN) {
int x = (int) event.getX();
int y = (int) event.getY();
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
Layout layout = widget.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
if (link.length != 0) {
if (action == MotionEvent.ACTION_UP) {
link[0].onClick(widget);
} else if (action == MotionEvent.ACTION_DOWN) {
Selection.setSelection(buffer,
buffer.getSpanStart(link[0]),
buffer.getSpanEnd(link[0]));
}
return true;
} else {
Selection.removeSelection(buffer);
Touch.onTouchEvent(widget, buffer, event);
return false;
}
}
return Touch.onTouchEvent(widget, buffer, event);
}
示例6: onTakeFocus
import android.text.Selection; //导入方法依赖的package包/类
public void onTakeFocus(TextView view, Spannable text, int dir) {
Selection.removeSelection(text);
if ((dir & 1) != 0) {
text.setSpan(FROM_BELOW, 0, 0, 34);
} else {
text.removeSpan(FROM_BELOW);
}
}
示例7: highlightUrl
import android.text.Selection; //导入方法依赖的package包/类
private void highlightUrl(TextView textView, BetterLinkMovementExtended.ClickableSpanWithText spanWithText, Spannable text) {
if (!this.isUrlHighlighted) {
this.isUrlHighlighted = true;
int spanStart = text.getSpanStart(spanWithText.span());
int spanEnd = text.getSpanEnd(spanWithText.span());
Selection.removeSelection(text);
text.setSpan(new BackgroundColorSpan(textView.getHighlightColor()), spanStart, spanEnd, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
textView.setText(text);
Selection.setSelection(text, spanStart, spanEnd);
}
}
示例8: removeUrlHighlightColor
import android.text.Selection; //导入方法依赖的package包/类
private void removeUrlHighlightColor(TextView textView) {
if (this.isUrlHighlighted) {
this.isUrlHighlighted = false;
Spannable text = (Spannable) textView.getText();
BackgroundColorSpan[] highlightSpans = text.getSpans(0, text.length(), BackgroundColorSpan.class);
for (BackgroundColorSpan highlightSpan : highlightSpans) {
text.removeSpan(highlightSpan);
}
try {
textView.setText(text);
Selection.removeSelection(text);
} catch (Exception ignored) {}
}
}
示例9: onTakeFocus
import android.text.Selection; //导入方法依赖的package包/类
@Override
public void onTakeFocus(TextView view, Spannable text, int dir) {
Selection.removeSelection(text);
if ((dir & View.FOCUS_BACKWARD) != 0) {
text.setSpan(FROM_BELOW, 0, 0, Spannable.SPAN_POINT_POINT);
} else {
text.removeSpan(FROM_BELOW);
}
}
示例10: onTouchEvent
import android.text.Selection; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(TextView textView, Spannable spannable, MotionEvent event) {
boolean handled = false;
if (event.getAction() == MotionEvent.ACTION_DOWN) {
pressedSpan = getPressedSpan(textView, spannable, event);
if (pressedSpan != null) {
pressedSpan.setPressed(true);
Selection.setSelection(spannable, spannable.getSpanStart(pressedSpan),
spannable.getSpanEnd(pressedSpan));
handled = true;
}
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
TouchableUrlSpan touchedSpan = getPressedSpan(textView, spannable, event);
if (pressedSpan != null && touchedSpan != pressedSpan) {
pressedSpan.setPressed(false);
pressedSpan = null;
Selection.removeSelection(spannable);
}
} else {
if (pressedSpan != null) {
pressedSpan.setPressed(false);
super.onTouchEvent(textView, spannable, event);
handled = true;
}
pressedSpan = null;
Selection.removeSelection(spannable);
}
return handled;
}
示例11: onTouchEvent
import android.text.Selection; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(TextView widget, Spannable buffer,
MotionEvent event) {
int action = event.getAction();
if (action == MotionEvent.ACTION_UP ||
action == MotionEvent.ACTION_DOWN) {
int x = (int) event.getX();
int y = (int) event.getY();
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
Layout layout = widget.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
if (link.length != 0) {
if (action == MotionEvent.ACTION_UP) {
handleLinkClick(link[0], widget);
} else {
Selection.setSelection(buffer,
buffer.getSpanStart(link[0]),
buffer.getSpanEnd(link[0]));
}
return true;
} else {
Selection.removeSelection(buffer);
}
}
return false;
}
示例12: onTouchEvent
import android.text.Selection; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(final TextView widget, final Spannable buffer, MotionEvent event) {
final int action = event.getAction();
if(action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) {
int x = (int) event.getX();
int y = (int) event.getY();
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
final Layout layout = widget.getLayout();
final int line = layout.getLineForVertical(y);
final int off = layout.getOffsetForHorizontal(line, x);
final ClickableSpan[] clickable = buffer.getSpans(off, off, ClickableSpan.class);
if(clickable.length != 0) {
if(action == MotionEvent.ACTION_UP) {
clickable[0].onClick(widget);
triggerSpanHit(widget);
}
return true;
} else {
Selection.removeSelection(buffer);
Touch.onTouchEvent(widget, buffer, event);
return false;
}
}
return Touch.onTouchEvent(widget, buffer, event);
}
示例13: onTouchEvent
import android.text.Selection; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_UP
|| event.getAction() == MotionEvent.ACTION_CANCEL
|| event.getAction() == MotionEvent.ACTION_HOVER_EXIT
|| event.getAction() == MotionEvent.ACTION_OUTSIDE) {
Selection.removeSelection(buffer);
}
return super.onTouchEvent(widget, buffer, event);
}
示例14: onTouchEvent
import android.text.Selection; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(TextView widget, Spannable buffer,
MotionEvent event) {
int action = event.getAction();
if (action == MotionEvent.ACTION_UP ||
action == MotionEvent.ACTION_DOWN) {
int x = (int) event.getX();
int y = (int) event.getY();
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
Layout layout = widget.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
if (link.length != 0) {
if (action == MotionEvent.ACTION_UP) {
String url = ((URLSpan) link[0]).getURL();
if (!IntentHandler.handle(url))
link[0].onClick(widget);
} else {
Selection.setSelection(buffer,
buffer.getSpanStart(link[0]),
buffer.getSpanEnd(link[0]));
}
return true;
} else {
Selection.removeSelection(buffer);
}
}
return super.onTouchEvent(widget, buffer, event);
}
示例15: onTouchEvent
import android.text.Selection; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(TextView widget, Spannable buffer,
MotionEvent event) {
int action = event.getAction();
if (action == MotionEvent.ACTION_UP ||
action == MotionEvent.ACTION_DOWN) {
int x = (int) event.getX();
int y = (int) event.getY();
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
Layout layout = widget.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
AbsEmojSpan[] link = buffer.getSpans(off, off, AbsEmojSpan.class);
if (link.length != 0) {
if (action == MotionEvent.ACTION_UP) {
link[0].onClick(widget);
} else if (action == MotionEvent.ACTION_DOWN) {
Selection.setSelection(buffer,
buffer.getSpanStart(link[0]),
buffer.getSpanEnd(link[0]));
}
return true;
} else {
Selection.removeSelection(buffer);
}
}
return super.onTouchEvent(widget, buffer, event);
}