Example usage for android.view MotionEvent ACTION_MASK

List of usage examples for android.view MotionEvent ACTION_MASK

Introduction

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

Prototype

int ACTION_MASK

To view the source code for android.view MotionEvent ACTION_MASK.

Click Source Link

Document

Bit mask of the parts of the action code that are the action itself.

Usage

From source file:com.putao.widget.touchgallery.GalleryWidget.GalleryViewPager.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
        //super.onInterceptTouchEvent(event);
        float endX = event.getX();
        float endY = event.getY();
        if (isAClick(startX, endX, startY, endY)) {
            if (mOnItemClickListener != null) {
                mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem());
            }/*from w w  w.ja v  a  2 s .c o m*/
            //launchFullPhotoActivity(imageUrls);// WE HAVE A CLICK!!
        } else {
            super.onTouchEvent(event);
        }
    }
    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        startX = event.getX();
        startY = event.getY();
    }
    /*if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP)
    {
    super.onTouchEvent(event);
    }*/
    float[] difference = handleMotionEvent(event);
    if (mCurrentView.pagerCanScroll()) {
        return super.onTouchEvent(event);
    } else {
        if (difference != null && mCurrentView.onRightSide && difference[0] < 0) //move right
        {
            return super.onTouchEvent(event);
        }
        if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) //move left
        {
            return super.onTouchEvent(event);
        }
        if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) {
            return super.onTouchEvent(event);
        }
    }
    return false;
}

From source file:com.lib.imagesee.GalleryViewPager.java

@Override
public boolean onTouchEvent(MotionEvent event) {

    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
        // super.onInterceptTouchEvent(event);

        float endX = event.getX();
        float endY = event.getY();
        if (isAClick(startX, endX, startY, endY)) {
            if (mOnItemClickListener != null) {
                mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem());
            }/*from  w  w  w.  j av  a  2 s  .c o m*/
            // launchFullPhotoActivity(imageUrls);// WE HAVE A CLICK!!
        } else {
            try {
                super.onTouchEvent(event);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        startX = event.getX();
        startY = event.getY();
    }

    /*
     * if ((event.getAction() & MotionEvent.ACTION_MASK) ==
     * MotionEvent.ACTION_UP) { super.onTouchEvent(event); }
     */

    float[] difference = handleMotionEvent(event);

    if (mCurrentView.pagerCanScroll()) {
        try {
            return super.onTouchEvent(event);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        if (difference != null && mCurrentView.onRightSide && difference[0] < 0) // move right
        {
            try {
                return super.onTouchEvent(event);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) // move left
        {
            try {
                return super.onTouchEvent(event);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) {
            try {
                return super.onTouchEvent(event);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    return false;
}

From source file:cn.dreamtobe.touchgallery.GalleryWidget.GalleryViewPager.java

@Override
public boolean onTouchEvent(MotionEvent event) {

    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
        //super.onInterceptTouchEvent(event);

        float endX = event.getX();
        float endY = event.getY();
        if (isAClick(startX, endX, startY, endY)) {
            if (mOnItemClickListener != null) {
                mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem());
            }// ww w  .jav  a2 s  .  c  om
            //launchFullPhotoActivity(imageUrls);// WE HAVE A CLICK!!
        } else {
            super.onTouchEvent(event);
        }
    }

    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        startX = event.getX();
        startY = event.getY();
    }

    /*if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP)
    {
    super.onTouchEvent(event);
    }*/

    float[] difference = handleMotionEvent(event);

    if (mCurrentView.pagerCanScroll()) {
        return super.onTouchEvent(event);
    } else {
        if (difference != null && mCurrentView.onRightSide && difference[0] < 0) //move right
        {
            return super.onTouchEvent(event);
        }
        if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) //move left
        {
            return super.onTouchEvent(event);
        }
        if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) {
            return super.onTouchEvent(event);
        }
    }

    return false;
}

From source file:com.fw.GalleryWidget.GalleryViewPager.java

@Override
public boolean onTouchEvent(MotionEvent event) {

    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
        //super.onInterceptTouchEvent(event);

        float endX = event.getX();
        float endY = event.getY();
        if (isAClick(startX, endX, startY, endY)) {
            if (mOnItemClickListener != null) {
                mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem());

            }//from  ww w .  j a  v a  2s . c o m
            //launchFullPhotoActivity(imageUrls);// WE HAVE A CLICK!!
        } else {
            super.onTouchEvent(event);
        }
    }

    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        startX = event.getX();
        startY = event.getY();
    }

    /*if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP)
    {
    super.onTouchEvent(event);
    }*/

    float[] difference = handleMotionEvent(event);

    if (mCurrentView.pagerCanScroll()) {
        return super.onTouchEvent(event);
    } else {
        if (difference != null && mCurrentView.onRightSide && difference[0] < 0) //move right
        {
            return super.onTouchEvent(event);
        }
        if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) //move left
        {
            return super.onTouchEvent(event);
        }
        if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) {
            return super.onTouchEvent(event);
        }
    }

    return false;
}

From source file:com.common.view.touchgallery.GalleryWidget.GalleryViewPager.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
        // super.onInterceptTouchEvent(event);
        float endX = event.getX();
        float endY = event.getY();
        if (isAClick(startX, endX, startY, endY)) {
            if (mOnItemClickListener != null) {
                mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem());
            }//from   www.j a v a  2 s .c  o  m
            // launchFullPhotoActivity(imageUrls);// WE HAVE A CLICK!!
        } else {
            super.onTouchEvent(event);
        }
    }
    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        startX = event.getX();
        startY = event.getY();
    }
    /*
     * if ((event.getAction() & MotionEvent.ACTION_MASK) ==
     * MotionEvent.ACTION_UP) { super.onTouchEvent(event); }
     */

    float[] difference = handleMotionEvent(event);
    if (null == mCurrentView)
        return false;
    if (mCurrentView.pagerCanScroll()) {
        return super.onTouchEvent(event);
    } else {
        if (difference != null && mCurrentView.onRightSide && difference[0] < 0) {// move right
            return super.onTouchEvent(event);
        }
        if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) { // move left
            return super.onTouchEvent(event);
        }
        if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) {
            return super.onTouchEvent(event);
        }
    }
    return false;
}

From source file:com.example.imageadapter.GalleryViewPager.java

@Override
public boolean onTouchEvent(MotionEvent event) {

    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
        //super.onInterceptTouchEvent(event);

        float endX = event.getX();
        float endY = event.getY();
        if (isAClick(startX, endX, startY, endY)) {
            if (mOnItemClickListener != null) {
                mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem());

            }/* w  w  w  .  ja v  a  2s.c  o m*/
            //launchFullPhotoActivity(imageUrls);// WE HAVE A CLICK!!
        } else {

            super.onTouchEvent(event);
        }
    }

    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        startX = event.getX();
        startY = event.getY();
    }

    /*if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP)
    {
    super.onTouchEvent(event);
    }*/

    float[] difference = handleMotionEvent(event);

    if (mCurrentView.pagerCanScroll()) {
        return super.onTouchEvent(event);
    } else {
        if (difference != null && mCurrentView.onRightSide && difference[0] < 0) //move right
        {
            return super.onTouchEvent(event);
        }
        if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) //move left
        {
            return super.onTouchEvent(event);
        }
        if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) {
            return super.onTouchEvent(event);
        }
    }

    return false;
}

From source file:com.liangxun.yuejiula.galleryweidget.GalleryViewPager.java

@TargetApi(Build.VERSION_CODES.ECLAIR)
private float[] handleMotionEvent(MotionEvent event) {
    try {/*from  ww w .j  av a 2  s .c o  m*/
        switch (event.getAction() & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            last = new PointF(event.getX(0), event.getY(0));
            break;
        case MotionEvent.ACTION_MOVE:
        case MotionEvent.ACTION_UP:
            PointF curr = new PointF(event.getX(0), event.getY(0));
            return new float[] { curr.x - last.x, curr.y - last.y };

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.jifeng.touchgallery.GalleryWidget.GalleryViewPager.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    try {/*from   ww  w  .j  a v  a2s  .c  om*/
        if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
            // super.onInterceptTouchEvent(event);

            float endX = event.getX();
            float endY = event.getY();
            if (isAClick(startX, endX, startY, endY)) {
                if (mOnItemClickListener != null) {
                    mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem());
                }
                // launchFullPhotoActivity(imageUrls);// WE HAVE A CLICK!!
            } else {
                super.onTouchEvent(event);
            }
        }

        if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
            startX = event.getX();
            startY = event.getY();
        }

        /*
         * if ((event.getAction() & MotionEvent.ACTION_MASK) ==
         * MotionEvent.ACTION_UP) { super.onTouchEvent(event); }
         */

        float[] difference = handleMotionEvent(event);

        if (mCurrentView.pagerCanScroll()) {
            return super.onTouchEvent(event);
        } else {
            if (difference != null && mCurrentView.onRightSide && difference[0] < 0) // move right
            {
                return super.onTouchEvent(event);
            }
            if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) // move left
            {
                return super.onTouchEvent(event);
            }
            if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) {
                return super.onTouchEvent(event);
            }
        }
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        //   Log.i("11111", e.toString());
        e.printStackTrace();
    }
    return false;
}

From source file:net.henryco.opalette.application.programs.sub.programs.gradient.PaletteRegionControl.java

@Override
protected void onFragmentCreate(View view, AppMainProto context, @Nullable Bundle savedInstanceState) {
    touchLines.setVisible(true);// ww w .ja  v a  2s  .c o m
    context.getRenderSurface().update();

    listener = event -> {
        final int action = event.getAction();
        final int count = event.getPointerCount();
        if (count >= 2) {
            switch (action & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_MOVE: {
                touchLines.setPoints(event.getX(0), event.getY(0), event.getX(1), event.getY(1));
                context.getRenderSurface().update();
                break;
            }
            }
        }
    };

    OPallViewInjector<AppMainProto> controls = new OPallViewInjector<AppMainProto>(view,
            R.layout.palette_region_layout) {
        @Override
        protected void onInject(AppMainProto context, View view) {
            final TextView reg = (TextView) view.findViewById(R.id.paletteTextRegion);
            final TextView non = (TextView) view.findViewById(R.id.paletteTextNone);
            final Button regButton = (Button) view.findViewById(R.id.bwButtonOn);
            final Button nonButton = (Button) view.findViewById(R.id.bwButtonOff);

            final int fca = ContextCompat.getColor(context.getActivityContext(), TEXT_COLOR_BLACK_OVERLAY);
            final int fcb = 0xFF000000;

            reg.setTextColor(touchLines.isDefault() ? fca : fcb);
            non.setTextColor(touchLines.isDefault() ? fcb : fca);

            backListener = context.getRenderSurface().getLastTouchEventListener();
            context.getRenderSurface().removeTouchEventListener(backListener);

            if (!touchLines.isDefault())
                context.getRenderSurface().addOnTouchEventListener(listener);

            regButton.setOnClickListener(
                    v -> OPallAnimated.pressButton75_225(context.getActivityContext(), v, () -> {
                        if (touchLines.isDefault())
                            context.getRenderSurface().addOnTouchEventListener(listener);
                        reg.setTextColor(fcb);
                        non.setTextColor(fca);
                    }));

            nonButton.setOnClickListener(
                    v -> OPallAnimated.pressButton75_225(context.getActivityContext(), v, () -> {
                        context.getRenderSurface().removeTouchEventListener(listener);
                        non.setTextColor(fcb);
                        reg.setTextColor(fca);
                        touchLines.reset();
                        context.getRenderSurface().update();
                    }));
        }
    };

    OPallViewInjector.inject(context.getActivityContext(), controls);

    if (palette.getOrientation() == OPalette.ORIENTATION_NONE) {
        new OPallAlertDialog()
                .message(context.getActivityContext().getResources().getString(R.string.palette_pick_warn))
                .show(context.getActivityContext().getSupportFragmentManager(), "Palette alert");
    }
}

From source file:com.example.picturebrower.Gallery.GalleryViewPager.java

@Override
public boolean onTouchEvent(MotionEvent event) {

    Log.i("jimmy viewpager", "touch");

    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
        //super.onInterceptTouchEvent(event);

        float endX = event.getX();
        float endY = event.getY();
        if (isAClick(startX, endX, startY, endY)) {
            if (mOnItemClickListener != null) {
                mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem());
            }//from  w w  w .  ja v a 2 s. c  o m
            //launchFullPhotoActivity(imageUrls);// WE HAVE A CLICK!!
        } else {
            super.onTouchEvent(event);
        }
    }

    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        startX = event.getX();
        startY = event.getY();
        Log.i("jimmy viewpager", "x=" + startX + "  " + "y=" + startY);
    }

    /*if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP)
    {
    super.onTouchEvent(event);
    }*/

    float[] difference = handleMotionEvent(event);

    if (mCurrentView.pagerCanScroll()) {
        return super.onTouchEvent(event);
    } else {
        if (difference != null && mCurrentView.onRightSide && difference[0] < 0) //move right
        {
            return super.onTouchEvent(event);
        }
        if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) //move left
        {
            return super.onTouchEvent(event);
        }
        if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) {
            return super.onTouchEvent(event);
        }
    }

    return false;
}