Example usage for android.view MotionEvent getRawY

List of usage examples for android.view MotionEvent getRawY

Introduction

In this page you can find the example usage for android.view MotionEvent getRawY.

Prototype

public final float getRawY() 

Source Link

Document

Returns the original raw Y coordinate of this event.

Usage

From source file:org.zywx.wbpalmstar.engine.EBounceView.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    }//from  w w  w  . jav  a  2 s.c o m
    mVelocityTracker.addMovement(event);
    int y = (int) event.getRawY();
    int action = event.getAction();
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        mLastY = y;
        break;
    case MotionEvent.ACTION_MOVE:
        int m = y - mLastY;
        if (mIsTop) {
            moveDown(m);
        } else if (mIsBottom) {
            moveUp(m);
        }
        mLastY = y;
        break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_OUTSIDE:
        reverse();
        handlerTracker();
        break;
    }
    return true;
}

From source file:com.hrs.filltheform.dialog.FillTheFormDialog.java

private void prepareDialogView() {
    windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    dialogParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT);

    dialogView = new FrameLayout(context);
    dialogView.setOnTouchListener(new View.OnTouchListener() {
        final Point screenSize = new Point();

        @Override//from w  w w .  j  a va 2 s . c  o  m
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                windowManager.getDefaultDisplay().getSize(screenSize);
                model.setScreenDimensions(screenSize.x, screenSize.y);
                model.setInitialDialogPosition(dialogParams.x, dialogParams.y);
                model.setInitialTouchEvent(event.getRawX(), event.getRawY());
                return true;
            case MotionEvent.ACTION_UP:
                model.onActionUp();
                return true;
            case MotionEvent.ACTION_MOVE:
                model.onActionMove(event.getRawX(), event.getRawY());
                return true;
            }
            return false;
        }
    });

    @SuppressLint("InflateParams")
    final View dialogContent = LayoutInflater.from(context).inflate(R.layout.dialog, null);
    dialogMenu = dialogContent.findViewById(R.id.dialog_menu);
    expandIcon = dialogContent.findViewById(R.id.expand_icon);
    expandIconFastMode = dialogContent.findViewById(R.id.expand_icon_fast_mode);

    // Set up dialog content
    ImageButton closeButton = (ImageButton) dialogContent.findViewById(R.id.close_button);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            model.onCloseButtonClicked();
        }
    });
    ImageButton minimizeButton = (ImageButton) dialogContent.findViewById(R.id.minimize_button);
    minimizeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            model.onMinimizeButtonClicked();
        }
    });
    ImageButton openFillTheFormAppButton = (ImageButton) dialogContent
            .findViewById(R.id.open_fill_the_form_app_button);
    openFillTheFormAppButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            model.onOpenFillTheFormAppButtonClicked();
        }
    });
    fastModeButton = (ImageButton) dialogContent.findViewById(R.id.fast_mode_button);
    fastModeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            model.toggleFastMode();
        }
    });

    // Configuration items list
    configurationItemsView = (RecyclerView) dialogContent.findViewById(R.id.configuration_items_view);
    configurationItemsView.setHasFixedSize(true);
    configurationItemsView.setLayoutManager(new LinearLayoutManager(context));
    // Set adapter
    configurationItemsAdapter = new ConfigurationItemsAdapter(context, model);
    configurationItemsView.setAdapter(configurationItemsAdapter);
    dialogView.addView(dialogContent);
}

From source file:com.appsimobile.appsii.SidebarHotspot.java

private void cancelMotionHandling(MotionEvent e, boolean cancelled) {
    mState = STATE_WAITING;//from www  . j a v  a  2 s.co  m
    if (mSwipeListener != null) {
        if (e == null) {
            mSwipeListener.onSwipeEnd(this, 0, 0, cancelled, mVelocityTracker);
        } else {
            mSwipeListener.onSwipeEnd(this, (int) e.getRawX(), (int) e.getRawY(), cancelled, mVelocityTracker);
        }
    }
    if (mCallback != null) {
        mCallback.cancelVisualHints(this);
    }
    mSwipeInProgress = false;
    mSwipeListener = null;

    // restore the background
    setBackground(mBackground);
    mIsDragOpening = false;

    if (mCallback != null) {
        mCallback.removeIfNeeded(this);
    }
    invalidate();

    mVelocityTracker.addMovement(e);
    mVelocityTracker.recycle();
    mVelocityTracker = null;
}

From source file:com.fastaccess.ui.modules.repos.RepoPagerActivity.java

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    if (navType == RepoPagerMvp.ISSUES && filterLayout.isShown()) {
        Rect viewRect = ViewHelper.getLayoutPosition(filterLayout);
        if (!viewRect.contains((int) ev.getRawX(), (int) ev.getRawY())) {
            hideFilterLayout();/*w  w w . j a  v  a2 s  .c o m*/
        }
    }
    return super.dispatchTouchEvent(ev);
}

From source file:arun.com.chromer.webheads.ui.views.WebHead.java

/**
 * Responsible for moving the web heads around and for locking/unlocking the web head to
 * remove view.// w w  w.ja  va  2s .  c  o m
 *
 * @param event the touch event
 */
private void handleMove(@NonNull MotionEvent event) {
    movementTracker.addMovement(event);

    float offsetX = event.getRawX() - posX;
    float offsetY = event.getRawY() - posY;

    if (Math.hypot(offsetX, offsetY) > touchSlop) {
        dragging = true;
    }

    if (dragging) {
        getTrashy().reveal();

        userManuallyMoved = true;

        int x = (int) (initialDownX + offsetX);
        int y = (int) (initialDownY + offsetY);

        if (isNearRemoveCircle(x, y)) {
            getTrashy().grow();
            touchUp();

            xSpring.setSpringConfig(SpringConfigs.SNAP);
            ySpring.setSpringConfig(SpringConfigs.SNAP);

            xSpring.setEndValue(trashLockCoOrd()[0]);
            ySpring.setEndValue(trashLockCoOrd()[1]);

        } else {
            getTrashy().shrink();

            xSpring.setSpringConfig(SpringConfigs.DRAG);
            ySpring.setSpringConfig(SpringConfigs.DRAG);

            xSpring.setCurrentValue(x);
            ySpring.setCurrentValue(y);

            touchDown();
        }
    }
}

From source file:com.billooms.harppedals.HarpPedalsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    //      Log.d(TAG, "HarpPedalsActivity.onCreate");
    super.onCreate(savedInstanceState);

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    dialogBuilder = new AlertDialog.Builder(this);
    dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override//from   w w  w .  j av a  2  s  .c  o m
        public void onClick(DialogInterface dialog, int which) {
            // don't do anything except close the dialog
        }
    });

    // This will be either the standard (small) layout or the large layout
    setContentView(R.layout.activity_main);

    // Check that the activity is using the standard (small) layout version with the 'fragment_container' FrameLayout
    if (findViewById(R.id.fragment_container) != null) {
        // Gesture Detector to detect horizontal swipes
        if (gDetector == null) {
            gDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
                @Override
                public boolean onFling(MotionEvent start, MotionEvent finish, float xVelocity,
                        float yVelocity) {
                    if ((finish == null) || (start == null)) { // not sure why, but the float dx = gives null pointer error sometimes
                        return false;
                    }
                    Fragment swipeFragment = getSupportFragmentManager().findFragmentByTag(NO_SWIPE);
                    if (swipeFragment == null) { // only process swipes in one-pane PedalFragments
                        float dx = finish.getRawX() - start.getRawX();
                        float dy = finish.getRawY() - start.getRawY();
                        if (Math.abs(dy) < Math.abs(dx)) { // horizontal
                            if (dx < 0) { // swipe toward the left for KeySignature
                                launchKeyFragment();
                            } else { // swipe toward the right for Chord
                                launchChordFragment();
                            }
                        }
                        return true; // gesture has been consumed
                    }
                    return false; // don't process swipes if we're not in a one-pane PedalFragment
                }
            });
        }

        // If we're being restored from a previous state,
        // then we don't need to do anything and should return or else
        // we could end up with overlapping fragments.
        if (savedInstanceState != null) {
            return;
        }

        // Create a new PedalFragment to be placed in the activity layout
        PedalFragment pedalFragment = new PedalFragment();
        // Add the fragment to the 'fragment_container' FrameLayout
        getSupportFragmentManager().beginTransaction()
                .add(R.id.fragment_container, pedalFragment, TAG_PEDAL_FRAG).commit();
    }
}

From source file:com.taobao.weex.ui.view.listview.BaseBounceView.java

@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (mGestureDetector != null) {
        mGestureDetector.onTouchEvent(ev);
    }//  w  w w  .  j  a  va  2 s  .  c  o  m
    switch (ev.getAction()) {
    case MotionEvent.ACTION_DOWN: {
        if (ev.getEdgeFlags() != 0) {
            return false;
        }
        mLastMotionX = ev.getRawX();
        mLastMotionY = ev.getRawY();
        mScrollValue = -getPaddingTop();
        return mIsBeingDragged;
    }
    case MotionEvent.ACTION_MOVE: {
        if (mIsBeingDragged) {
            float y = ev.getRawY();
            startPull(y);
            return true;
        }
        break;
    }
    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP: {
        if (mIsBeingDragged) {
            this.mScrollValue = -getPaddingTop();
            mIsBeingDragged = false;
            onTouchActionUp();
            if (mMaxPadding > 0) {
                /**
                 * 1.listview?paddingTop?0????0deltaY?paddingTop < 0
                 * 2.listview??PADDING????PADDINGdeltaY(-PADDING - getPaddingTop()) > 0
                 * bug:
                 * listview item?2?listview??pull
                 * fix
                 * listview??
                 */
                if (getPaddingTop() > 0/*|| getPaddingTop() < -mMaxPadding*/) {
                    mScrollValue = getPaddingTop() > 0 ? 0 : -mMaxPadding;
                    backToInitPos(getPaddingTop(),
                            getPaddingTop() > 0 ? -getPaddingTop() : (-mMaxPadding - getPaddingTop()));
                }
            } else {
                backToInitPos(getScrollY(), -getScrollY());
            }
            mMode = null;
            return true;
        }
        break;
    }
    }
    return false;
}

From source file:com.prevas.redmine.NewIssueActivity.java

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    View view = getCurrentFocus();
    boolean ret = super.dispatchTouchEvent(event);

    if (view instanceof EditText) {
        View v = getCurrentFocus();
        int scrcoords[] = new int[2];
        v.getLocationOnScreen(scrcoords);
        float x = event.getRawX() + v.getLeft() - scrcoords[0];
        float y = event.getRawY() + v.getTop() - scrcoords[1];

        if (event.getAction() == MotionEvent.ACTION_UP
                && (x < v.getLeft() || x >= v.getRight() || y < v.getTop() || y > v.getBottom())) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0);
        }//from www  .  j  a  v a2s.c  om
    }
    return ret;
}

From source file:com.devbrackets.android.recyclerext.decoration.ReorderDecoration.java

/**
 * Manually starts the reorder process for the specified view.  This should not be used if the {@link #setDragHandleId(int)} is
 * set and should control the reordering.
 *
 * @param view The View to start reordering
 * @param startMotionEvent The MotionEvent that starts the reorder
 *//*from  w w w .java2  s .c  om*/
public void startReorder(View view, @Nullable MotionEvent startMotionEvent) {
    if (dragState == DragState.DRAGGING) {
        return;
    }

    if (startMotionEvent != null) {
        fingerOffset = new PointF(startMotionEvent.getRawX(), startMotionEvent.getRawY());

        int[] rawViewLoc = new int[2];
        view.getLocationOnScreen(rawViewLoc);
        fingerOffset.x = rawViewLoc[0] - fingerOffset.x;
        fingerOffset.y = rawViewLoc[1] - fingerOffset.y;
    }

    dragState = DragState.DRAGGING;
    dragItem = createDragBitmap(view);

    selectedDragItemPosition = recyclerView.getChildAdapterPosition(view);
}

From source file:arun.com.chromer.webheads.ui.views.WebHead.java

private void handleTouchDown(@NonNull MotionEvent event) {
    dragging = false;//from  w ww .  ja  v a  2 s. c o  m

    movementTracker.onDown();

    initialDownX = windowParams.x;
    initialDownY = windowParams.y;

    posX = event.getRawX();
    posY = event.getRawY();

    if (master) {
        masterDownX = (int) posX;
        masterDownY = (int) posY;
    }

    touchDown();

    cancelCoastingTask();
}