本文整理了Java中android.webkit.WebView.dispatchTouchEvent()
方法的一些代码示例,展示了WebView.dispatchTouchEvent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.dispatchTouchEvent()
方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:dispatchTouchEvent
暂无
代码示例来源:origin: ankidroid/Anki-Android
/** Tap onto the currently shown flashcard at position x and y
*
* @param x horizontal position of the event
* @param y vertical position of the event
*/
public void tapOnCurrentCard(int x, int y) {
// assemble suitable ACTION_DOWN and ACTION_UP events and forward them to the card's handler
MotionEvent eDown = MotionEvent.obtain(SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, x, y,
1, 1, 0, 1, 1, 0, 0);
mCard.dispatchTouchEvent(eDown);
MotionEvent eUp = MotionEvent.obtain(eDown.getDownTime(),
SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x, y,
1, 1, 0, 1, 1, 0, 0);
mCard.dispatchTouchEvent(eUp);
}
代码示例来源:origin: ankidroid/Anki-Android
mCard.dispatchTouchEvent(event);
代码示例来源:origin: smuyyh/BookReader
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (mActivityCallback == null)
mActivityCallback = (ReadEPubActivity) getContext();
final int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
mMoveOccured = false;
mDownPosX = event.getX();
mDownPosY = event.getY();
fragment.removeCallback();
break;
case MotionEvent.ACTION_UP:
if (!mMoveOccured) {
mActivityCallback.toggleToolBarVisible();
}
fragment.startCallback();
break;
case MotionEvent.ACTION_MOVE:
if (Math.abs(event.getX() - mDownPosX) > MOVE_THRESHOLD_DP
|| Math.abs(event.getY() - mDownPosY) > MOVE_THRESHOLD_DP) {
mMoveOccured = true;
fragment.fadeInSeekbarIfInvisible();
}
break;
}
return super.dispatchTouchEvent(event);
}
代码示例来源:origin: jeasonlzy/VerticalSlideView
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
downX = ev.getX();
downY = ev.getY();
//如果滑动到了最底部,就允许继续向上滑动加载下一页,否者不允许
getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_MOVE:
float dx = ev.getX() - downX;
float dy = ev.getY() - downY;
boolean allowParentTouchEvent;
if (Math.abs(dy) > Math.abs(dx)) {
if (dy > 0) {
//位于顶部时下拉,让父View消费事件
allowParentTouchEvent = isTop();
} else {
//位于底部时上拉,让父View消费事件
allowParentTouchEvent = isBottom();
}
} else {
//水平方向滑动
allowParentTouchEvent = true;
}
getParent().requestDisallowInterceptTouchEvent(!allowParentTouchEvent);
}
return super.dispatchTouchEvent(ev);
}
代码示例来源:origin: googlesamples/android-PermissionRequest
@Override
public void run() {
Rect rect = new Rect();
webView.getHitRect(rect);
int x = rect.width() / 2;
int y = 100;
MotionEvent event = MotionEvent.obtain(SystemClock.uptimeMillis(),
SystemClock.uptimeMillis() + 100, MotionEvent.ACTION_DOWN, x, y, 0);
webView.dispatchTouchEvent(event);
event = MotionEvent.obtain(SystemClock.uptimeMillis(),
SystemClock.uptimeMillis() + 100, MotionEvent.ACTION_UP, x, y, 0);
webView.dispatchTouchEvent(event);
}
});
代码示例来源:origin: org.seleniumhq.selenium/selenium-android-driver
public void run() {
float zoom = view.getScale();
for (MotionEvent event : events) {
event.setLocation(zoom * event.getX(), zoom * event.getY());
try {
event.setSource(InputDevice.SOURCE_CLASS_POINTER);
} catch (NoSuchMethodError e) {
throw new WebDriverException("You are using an Android WebDriver APK "
+ "for ICS SDKs or more recent SDK versions. For more info see "
+ "http://code.google.com/p/selenium/wiki/AndroidDriver#Supported_Platforms.", e);
}
view.dispatchTouchEvent(event);
synchronized (syncObject) {
done = true;
syncObject.notify();
}
}
}
});
代码示例来源:origin: stackoverflow.com
public void run() {
if (webview != null) {
webview.dispatchTouchEvent(motionEvent);
public void run() {
if (webview != null) {
webview.dispatchTouchEvent(motionEvent2);
内容来源于网络,如有侵权,请联系作者删除!