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


Java MotionEvent.ACTION_SCROLL属性代码示例

本文整理汇总了Java中android.view.MotionEvent.ACTION_SCROLL属性的典型用法代码示例。如果您正苦于以下问题:Java MotionEvent.ACTION_SCROLL属性的具体用法?Java MotionEvent.ACTION_SCROLL怎么用?Java MotionEvent.ACTION_SCROLL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.view.MotionEvent的用法示例。


在下文中一共展示了MotionEvent.ACTION_SCROLL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if(PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("widgetScroll", false)) {
        if (ev.getAction() == MotionEvent.ACTION_MOVE || ev.getAction() == MotionEvent.ACTION_SCROLL) {
            if(Math.abs(ev.getX()-lastX)<Math.abs(ev.getY()-lastY)) {
                for (int i = 0; i < getChildCount(); i++) {
                    View v = getChildAt(i);
                    if (v.getTag() instanceof Card.Apps) {
                        Card.Apps c = (Card.Apps) v.getTag();
                        float x = v.getX() + c.getCardContainer().getX();
                        float y = v.getY() + c.getCardContainer().getY();
                        float w = c.getCardContainer().getWidth();
                        float h = c.getCardContainer().getHeight();
                        if (ev.getX() >= x && ev.getX() < x + w && ev.getY() >= y && ev.getY() < y + h) {
                            return true;
                        } else break;
                    }
                }
            }
        }
    }
    lastX = ev.getX();
    lastY = ev.getY();
    return super.onInterceptTouchEvent(ev);
}
 
开发者ID:jathak,项目名称:sflauncher,代码行数:25,代码来源:SuperRecyclerView.java

示例2: dispatchTouchEvent

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
	// Check for clickable state and do nothing if disabled
	if(!this.isClickable()) {
		this.isSelected = false;
		return super.onTouchEvent(event);
	}

	// Set selected state based on Motion Event
	switch(event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			this.isSelected = true;
			break;
		case MotionEvent.ACTION_UP:
		case MotionEvent.ACTION_SCROLL:
		case MotionEvent.ACTION_OUTSIDE:
		case MotionEvent.ACTION_CANCEL:
			this.isSelected = false;
			break;
	}

	// Redraw image and return super type
	this.invalidate();
	return super.dispatchTouchEvent(event);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:CircularImageView.java

示例3: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (!this.isClickable()) {
        this.setSelected(false);
        return super.onTouchEvent(event);
    }

    if (!mIsTouchSelectModeEnabled) {
        return super.onTouchEvent(event);
    }
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            this.setSelected(true);
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_SCROLL:
        case MotionEvent.ACTION_OUTSIDE:
        case MotionEvent.ACTION_CANCEL:
            this.setSelected(false);
            break;
    }
    return super.onTouchEvent(event);
}
 
开发者ID:coopese,项目名称:qmui,代码行数:23,代码来源:QMUIRadiusImageView.java

示例4: onGenericMotionEvent

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
	if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
		switch (event.getAction()) {
		case MotionEvent.ACTION_SCROLL: {
			if (mTouchMode == TOUCH_MODE_REST) {
				final float hscroll = event
						.getAxisValue(MotionEvent.AXIS_HSCROLL);
				if (hscroll != 0) {
					final int delta = (int) (hscroll * getHorizontalScrollFactor());
					if (!trackMotionScroll(delta, delta)) {
						return true;
					}
				}
			}
		}
		}
	}
	return super.onGenericMotionEvent(event);
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:21,代码来源:AbsHListView.java

示例5: dispatchTouchEvent

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    // Check for clickable state and do nothing if disabled
    if (!this.isClickable()) {
        this.isSelected = false;
        return super.onTouchEvent(event);
    }

    // Set selected state based on Motion Event
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            this.isSelected = true;
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_SCROLL:
        case MotionEvent.ACTION_OUTSIDE:
        case MotionEvent.ACTION_CANCEL:
            this.isSelected = false;
            break;
    }

    // Redraw image and return super type
    this.invalidate();
    return super.dispatchTouchEvent(event);
}
 
开发者ID:TaRGroup,项目名称:CoolApk-Console,代码行数:25,代码来源:BezelImageView.java

示例6: onGenericMotionEvent

@Override
public boolean onGenericMotionEvent(MotionEvent event) {

	if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
		switch (event.getAction()) {
		case MotionEvent.ACTION_SCROLL: {
			final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
			if(DBG) Log.d(TAG,"onGenericMotionEvent ACTION_SCROLL vscroll="+vscroll);
			if (vscroll != 0) {
				final int index = mLayout.getFrontCoverIndex();
				int targetIndex;
				if (index+vscroll<0) {
					targetIndex=0;
				} else if (index+vscroll >= mCovers.size()-1) {
					targetIndex = mCovers.size()-1;
				} else {
					targetIndex = (int)(index+vscroll+0.5);
				}
				float targetScroll = mLayout.getScrollingPositionToCenterThisCover(targetIndex);
				mAnimHandler.startScrollingAnimPosition(targetScroll, AnimHandler.SPEED_FAST);
			}
		}
		}
	}
	return super.onGenericMotionEvent(event);
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:26,代码来源:CoverRoll3D.java

示例7: processGenericEvent

public void processGenericEvent(final MotionEvent event)
{
	// Joysticks are supported since Honeycomb, but I don't care about it, because very few devices have it
	if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK )
	{
		// event.getAxisValue(AXIS_HAT_X) and event.getAxisValue(AXIS_HAT_Y) are joystick arrow keys, on Nvidia Shield and some other joysticks
		DemoGLSurfaceView.nativeGamepadAnalogJoystickInput(
			event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y),
			event.getAxisValue(MotionEvent.AXIS_Z), event.getAxisValue(MotionEvent.AXIS_RZ),
			event.getAxisValue(MotionEvent.AXIS_LTRIGGER), event.getAxisValue(MotionEvent.AXIS_RTRIGGER),
			event.getAxisValue(MotionEvent.AXIS_HAT_X), event.getAxisValue(MotionEvent.AXIS_HAT_Y),
			processGamepadDeviceId(event.getDevice()) );
		return;
	}
	// Process mousewheel
	if( event.getAction() == MotionEvent.ACTION_SCROLL )
	{
		int scrollX = Math.round(event.getAxisValue(MotionEvent.AXIS_HSCROLL));
		int scrollY = Math.round(event.getAxisValue(MotionEvent.AXIS_VSCROLL));
		DemoGLSurfaceView.nativeMouseWheel(scrollX, scrollY);
		return;
	}
	super.processGenericEvent(event);
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:24,代码来源:Video.java

示例8: onGenericMotionEvent

@Override
@TargetApi(12)
public boolean onGenericMotionEvent(MotionEvent event) {
	if ((MotionEventCompat.getSource(event) & InputDevice.SOURCE_CLASS_POINTER) != 0) {
		switch (event.getAction()) {
		case MotionEvent.ACTION_SCROLL:
			// Process scroll wheel movement:
			float yDistance = MotionEventCompat.getAxisValue(event, MotionEvent.AXIS_VSCROLL);

			vt320 vtBuffer = (vt320) terminalView.bridge.buffer;
			boolean mouseReport = vtBuffer.isMouseReportEnabled();
			if (mouseReport) {
				int row = (int) Math.floor(event.getY() / terminalView.bridge.charHeight);
				int col = (int) Math.floor(event.getX() / terminalView.bridge.charWidth);

				vtBuffer.mouseWheel(
						yDistance > 0,
						col,
						row,
						(event.getMetaState() & KeyEvent.META_CTRL_ON) != 0,
						(event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0,
						(event.getMetaState() & KeyEvent.META_META_ON) != 0);
				return true;
			}
		}
	}

	return super.onGenericMotionEvent(event);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:TerminalTextViewOverlay.java

示例9: onGenericMotionEvent

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_SCROLL: {
                // Handle mouse (or ext. device) by shifting the page depending on the scroll
                final float vscroll;
                final float hscroll;
                if ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0) {
                    vscroll = 0;
                    hscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                } else {
                    vscroll = -event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                    hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
                }
                if (hscroll != 0 || vscroll != 0) {
                    boolean isForwardScroll = mIsRtl ? (hscroll < 0 || vscroll < 0)
                                                     : (hscroll > 0 || vscroll > 0);
                    if (isForwardScroll) {
                        scrollRight();
                    } else {
                        scrollLeft();
                    }
                    return true;
                }
            }
        }
    }
    return super.onGenericMotionEvent(event);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:30,代码来源:PagedView.java

示例10: friendlyMotionEvent

private String friendlyMotionEvent(MotionEvent ev) {
    String action;

    if (ev != null) {
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                action = "ACTION_DOWN";
                break;
            case MotionEvent.ACTION_UP:
                action = "ACTION_UP";
                break;
            case MotionEvent.ACTION_MOVE:
                action = "ACTION_MOVE";
                break;
            case MotionEvent.ACTION_CANCEL:
                action = "ACTION_CANCEL";
                break;
            case MotionEvent.ACTION_SCROLL:
                action = "ACTION_SCROLL";
                break;
            default:
                action = String.valueOf(ev.getAction());

        }
    } else {
        action = "MotionEvent is null (action cannot be taken from it)";
    }

    return action;
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:30,代码来源:GesturedListView.java

示例11: onGenericMotion

@Override
public boolean onGenericMotion(View v, MotionEvent event) {
    float x, y;
    int action;

    switch ( event.getSource() ) {
        case InputDevice.SOURCE_JOYSTICK:
        case InputDevice.SOURCE_GAMEPAD:
        case InputDevice.SOURCE_DPAD:
            return SDLActivity.handleJoystickMotionEvent(event);

        case InputDevice.SOURCE_MOUSE:
            action = event.getActionMasked();
            switch (action) {
                case MotionEvent.ACTION_SCROLL:
                    x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
                    y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
                    SDLActivity.onNativeMouse(0, action, x, y);
                    return true;

                case MotionEvent.ACTION_HOVER_MOVE:
                    x = event.getX(0);
                    y = event.getY(0);

                    SDLActivity.onNativeMouse(0, action, x, y);
                    return true;

                default:
                    break;
            }
            break;

        default:
            break;
    }

    // Event was not managed
    return false;
}
 
开发者ID:jomof,项目名称:cdep-android-studio-freetype-sample,代码行数:39,代码来源:SDLActivity.java

示例12: actionToString

public static String actionToString(int action) {
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            return "ACTION_DOWN";
        case MotionEvent.ACTION_UP:
            return "ACTION_UP";
        case MotionEvent.ACTION_CANCEL:
            return "ACTION_CANCEL";
        case MotionEvent.ACTION_OUTSIDE:
            return "ACTION_OUTSIDE";
        case MotionEvent.ACTION_MOVE:
            return "ACTION_MOVE";
        case MotionEvent.ACTION_HOVER_MOVE:
            return "ACTION_HOVER_MOVE";
        case MotionEvent.ACTION_SCROLL:
            return "ACTION_SCROLL";
        case MotionEvent.ACTION_HOVER_ENTER:
            return "ACTION_HOVER_ENTER";
        case MotionEvent.ACTION_HOVER_EXIT:
            return "ACTION_HOVER_EXIT";
        case MotionEvent.ACTION_BUTTON_PRESS:
            return "ACTION_BUTTON_PRESS";
        case MotionEvent.ACTION_BUTTON_RELEASE:
            return "ACTION_BUTTON_RELEASE";
    }
    int index = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
    switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_POINTER_DOWN:
            return "ACTION_POINTER_DOWN(" + index + ")";
        case MotionEvent.ACTION_POINTER_UP:
            return "ACTION_POINTER_UP(" + index + ")";
        default:
            return Integer.toString(action);
    }
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:35,代码来源:ViewUtils.java

示例13: dispatchTouchEventForDialog

public boolean dispatchTouchEventForDialog(MotionEvent ev, Dialog dialog, final boolean consumed,
                                           Activity activity, boolean needClearFocus) {
    if (ev.getAction() == MotionEvent.ACTION_UP
            && ev.getAction() != MotionEvent.ACTION_SCROLL) {
        final View view = dialog.getWindow().getCurrentFocus();
        if (view != null) {
            final View viewTmp;
            viewTmp = dialog.getWindow().getCurrentFocus();
            final View viewNew = viewTmp != null ? viewTmp : view;
            if (viewNew.equals(view)) {
                final Rect rect = new Rect();
                final int[] coordinates = new int[2];

                view.getLocationOnScreen(coordinates);
                rect.set(coordinates[0], coordinates[1], coordinates[0] + view.getWidth(), coordinates[1] + view.getHeight());

                final int x = (int) ev.getRawX();
                final int y = (int) ev.getRawY();

                if (rect.contains(x, y)) {
                    return consumed;
                }
            } else if (viewNew instanceof EditText) {
                return consumed;
            }
            hideKeyboard(view, activity);
            if (needClearFocus) {
                viewNew.clearFocus();
            }
            return consumed;
        }
    }
    return consumed;
}
 
开发者ID:Omega-R,项目名称:OmegaKeyboard,代码行数:34,代码来源:AutoHideKeyboardHelper.java

示例14: dispatchTouchEventForActivity

public boolean dispatchTouchEventForActivity(MotionEvent ev, final boolean consumed,
                                             Activity activity, boolean needClearFocus) {
    if (ev.getAction() == MotionEvent.ACTION_UP
            && ev.getAction() != MotionEvent.ACTION_SCROLL) {
        final View view = activity.getCurrentFocus();
        if (view != null) {
            final View viewTmp = activity.getCurrentFocus();
            final View viewNew = viewTmp != null ? viewTmp : view;
            if (viewNew.equals(view)) {
                final Rect rect = new Rect();
                final int[] coordinates = new int[2];

                view.getLocationOnScreen(coordinates);
                rect.set(coordinates[0], coordinates[1], coordinates[0] + view.getWidth(), coordinates[1] + view.getHeight());

                final int x = (int) ev.getX();
                final int y = (int) ev.getY();
                if (rect.contains(x, y)) {
                    return consumed;
                }
            } else if (viewNew instanceof EditText) {
                return consumed;
            }
            hideKeyboard(view, activity);
            if (needClearFocus) {
                viewNew.clearFocus();
            }
            return consumed;
        }
    }
    return consumed;
}
 
开发者ID:Omega-R,项目名称:OmegaKeyboard,代码行数:32,代码来源:AutoHideKeyboardHelper.java

示例15: onGenericMotionEvent

/**
 * Overriding {@link View#onGenericMotionEvent(MotionEvent)}.
 */
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
    if (mEmulator != null && event.isFromSource(InputDevice.SOURCE_MOUSE) && event.getAction() == MotionEvent.ACTION_SCROLL) {
        // Handle mouse wheel scrolling.
        boolean up = event.getAxisValue(MotionEvent.AXIS_VSCROLL) > 0.0f;
        doScroll(event, up ? -3 : 3);
        return true;
    }
    return false;
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:13,代码来源:TerminalView.java


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