当前位置: 首页>>代码示例>>Java>>正文


Java Selection.removeSelection方法代码示例

本文整理汇总了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;
}
 
开发者ID:lsjwzh,项目名称:FastTextView,代码行数:36,代码来源:ClickableSpanUtil.java

示例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);
}
 
开发者ID:deliciousblackink,项目名称:Derpibooru,代码行数:22,代码来源:CustomFormattingMovementMethod.java

示例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);
}
 
开发者ID:alidili,项目名称:Demos,代码行数:29,代码来源:TouchLinkMovementMethod.java

示例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;
}
 
开发者ID:tylersuehr7,项目名称:social-text-view,代码行数:32,代码来源:AccurateMovementMethod.java

示例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);
}
 
开发者ID:RanKKI,项目名称:PSNine,代码行数:40,代码来源:LocalLinkMovementMethod.java

示例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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:LongClickableLinkMovementMethod.java

示例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);
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:12,代码来源:BetterLinkMovementExtended.java

示例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) {}
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:15,代码来源:BetterLinkMovementExtended.java

示例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);
    }
}
 
开发者ID:zhangdatao,项目名称:Emojier-Andriod,代码行数:11,代码来源:EMLinkMovementMethod.java

示例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;
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:30,代码来源:LinkTouchMovementMethod.java

示例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;
}
 
开发者ID:turbohappy,项目名称:ljcbestill,代码行数:40,代码来源:DevotionalLinkMethod.java

示例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);
}
 
开发者ID:tpb1908,项目名称:AndroidProjectsClient,代码行数:37,代码来源:ClickableMovementMethod.java

示例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);
}
 
开发者ID:skyfe79,项目名称:HashGirl,代码行数:12,代码来源:HashGirlLinkMovementMethod.java

示例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);
}
 
开发者ID:RadiationX,项目名称:ForPDA,代码行数:40,代码来源:LinkMovementMethod.java

示例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);
}
 
开发者ID:zhangdatao,项目名称:Emojier-Andriod,代码行数:40,代码来源:EMLinkMovementMethod.java


注:本文中的android.text.Selection.removeSelection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。