Example usage for android.view MotionEvent ACTION_OUTSIDE

List of usage examples for android.view MotionEvent ACTION_OUTSIDE

Introduction

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

Prototype

int ACTION_OUTSIDE

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

Click Source Link

Document

Constant for #getActionMasked : A movement has happened outside of the normal bounds of the UI element.

Usage

From source file:Main.java

public static String eventToString(MotionEvent event) {
    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
        return "DOWN";
    case MotionEvent.ACTION_MOVE:
        return "MOVE";
    case MotionEvent.ACTION_UP:
        return "UP";
    case MotionEvent.ACTION_CANCEL:
        return "CANCEL";
    case MotionEvent.ACTION_OUTSIDE:
        return "OUTSIDE";
    case MotionEvent.ACTION_POINTER_DOWN:
        return "POINTER DOWN";
    case MotionEvent.ACTION_POINTER_UP:
        return "POINTER UP";
    }/*  w w  w . java 2 s .c  o m*/
    return "UNKNOWN";
}

From source file:Main.java

public static String getTouchAction(int actionId) {
    String actionName = "Unknow:id=" + actionId;
    switch (actionId) {
    case MotionEvent.ACTION_DOWN:
        actionName = "ACTION_DOWN";
        break;//from   ww  w .j  a va 2 s .  c  om
    case MotionEvent.ACTION_MOVE:
        actionName = "ACTION_MOVE";
        break;
    case MotionEvent.ACTION_UP:
        actionName = "ACTION_UP";
        break;
    case MotionEvent.ACTION_CANCEL:
        actionName = "ACTION_CANCEL";
        break;
    case MotionEvent.ACTION_OUTSIDE:
        actionName = "ACTION_OUTSIDE";
        break;
    }
    return actionName;
}

From source file:Main.java

public static String getMotionEventString(int action) {
    switch (action) {
    case (MotionEvent.ACTION_DOWN):
        return "action_down";
    case (MotionEvent.ACTION_UP):
        return "action_down";
    case (MotionEvent.ACTION_CANCEL):
        return "action_down";
    case (MotionEvent.ACTION_MOVE):
        return "action_move";
    case (MotionEvent.ACTION_OUTSIDE):
        return "action_outside";
    case (MotionEvent.ACTION_HOVER_ENTER):
        return "action_hover_enter";
    case (MotionEvent.ACTION_HOVER_EXIT):
        return "action_hover_exit";
    case (MotionEvent.ACTION_HOVER_MOVE):
        return "action_hover_move";
    case (MotionEvent.ACTION_MASK):
        return "action_mask";
    }//from   w w w. j  a  v a 2s  .  c o  m
    return "unknown action event";
}

From source file:Main.java

/**
 * Gets the name of an action.//from   w w  w. j ava 2  s  . c om
 * 
 * @param action        The action being performed.
 * @param isMotionEvent Whether or not the action is a motion event.
 * 
 * @return The name of the action being performed.
 */
public static String getActionName(int action, boolean isMotionEvent) {
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        return "DOWN";
    case MotionEvent.ACTION_UP:
        return "UP";
    case MotionEvent.ACTION_MOVE:
        return isMotionEvent ? "MOVE" : "MULTIPLE";
    case MotionEvent.ACTION_CANCEL:
        return "CANCEL";
    case MotionEvent.ACTION_OUTSIDE:
        return "OUTSIDE";
    case MotionEvent.ACTION_POINTER_DOWN:
        return "POINTER_DOWN";
    case MotionEvent.ACTION_POINTER_UP:
        return "POINTER_UP";
    case MotionEvent.ACTION_HOVER_MOVE:
        return "HOVER_MOVE";
    case MotionEvent.ACTION_SCROLL:
        return "SCROLL";
    case MotionEvent.ACTION_HOVER_ENTER:
        return "HOVER_ENTER";
    case MotionEvent.ACTION_HOVER_EXIT:
        return "HOVER_EXIT";
    default:
        return "ACTION_" + Integer.toString(action);
    }
}

From source file:com.kaku.weac.activities.LifeIndexDetailActivity.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (MotionEvent.ACTION_OUTSIDE == event.getAction() || MotionEvent.ACTION_DOWN == event.getAction()) {
        onFinish();/*ww  w  .j  a v a 2 s.  co  m*/
        return true;
    }
    return super.onTouchEvent(event);
}

From source file:jp.co.cyberagent.android.gpuimage.sample.activity.ActivityGallery.java

@SuppressLint("NewApi")
@Override//w ww  .  ja va 2 s  .c om
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery);

    //Get height, width
    mWindowSize = new Point();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
        getWindowManager().getDefaultDisplay().getSize(mWindowSize);
    } else {
        Display display = getWindowManager().getDefaultDisplay();
        mWindowSize.x = display.getWidth();
        mWindowSize.y = display.getHeight();
    }
    Log.v(DEBUG_TAG, "Window Size  = " + mWindowSize.x + "  = " + mWindowSize.y);
    //((SeekBar) findViewById(R.id.seekBar)).setOnSeekBarChangeListener(this);
    //findViewById(R.id.button_choose_filter).setOnClickListener(this);
    //findViewById(R.id.button_save).setOnClickListener(this);

    mGPUImageView = (GPUImageView) findViewById(R.id.gpuimage);

    //Drawable water = getResources().getDrawable(R.drawable.water_over_coral_reef_303786);
    //BitmapDrawable = getResources().getDrawable(R.drawable.water_over_coral_reef_303786);
    Bitmap water = BitmapFactory.decodeResource(getResources(), R.drawable.water_over_coral_reef_303786);
    mGPUImageView.setImage(water);

    /*Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
    photoPickerIntent.setType("image/*");
    startActivityForResult(photoPickerIntent, REQUEST_PICK_IMAGE);*/

    switchFilterTo(new WaterRippleEffect(mWindowSize.x, mWindowSize.y));

    mGPUImageView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            int action = MotionEventCompat.getActionMasked(event);

            switch (action) {
            case (MotionEvent.ACTION_DOWN):
                Log.d(DEBUG_TAG, "Action was DOWN X = " + event.getX() + " | Y =" + event.getY());
                //if(mFilter.getClass() == WaterRippleEffect.class) {
                try {
                    float points[] = convertFromAndroiSpaceToOpenGL(event.getX(), event.getY());
                    ((WaterRippleEffect) mFilter).setTouches(points[0], points[1]);
                } catch (NullPointerException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                //}

                return true;
            case (MotionEvent.ACTION_MOVE):
                Log.d(DEBUG_TAG, "Action was MOVE");
                return true;
            case (MotionEvent.ACTION_UP):
                Log.d(DEBUG_TAG, "Action was UP");
                return true;
            case (MotionEvent.ACTION_CANCEL):
                Log.d(DEBUG_TAG, "Action was CANCEL");
                return true;
            case (MotionEvent.ACTION_OUTSIDE):
                Log.d(DEBUG_TAG, "Movement occurred outside bounds " + "of current screen element");
                return true;
            default:
                return true;
            }
        }
    });

}

From source file:com.greenkee.pokeADot.GameActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // tell system to use the layout defined in our XML file
    setContentView(com.greenkee.pokeADot.R.layout.activity_game_screen);

    mView = (GameView) findViewById(com.greenkee.pokeADot.R.id.gameScreen);
    mThread = mView.getThread();/* w w w  .  j a  v  a2 s  .co m*/
    mView.setActivity(this);
    ((GameView) mView).setTextViews((TextView) findViewById(com.greenkee.pokeADot.R.id.status_display),
            (TextView) findViewById(com.greenkee.pokeADot.R.id.score_display),
            (TextView) findViewById(com.greenkee.pokeADot.R.id.combo_display));

    if (savedInstanceState == null) {
        System.out.println("STATE SET");
        mThread.doStart();
    } else {
        super.onRestoreInstanceState(savedInstanceState);
        mThread.restoreState(savedInstanceState);

    }
    mView.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            int action = MotionEventCompat.getActionMasked(event);
            final int pointerIndex;
            final float x;
            final float y;
            switch (action) {
            case (MotionEvent.ACTION_DOWN): {
                //  System.out.println("ACTION_DOWN");
                if (((GameView.GameThread) mThread).getCurrentState() == GameView.GameThread.STATE_RUNNING) {
                    int index = MotionEventCompat.getActionIndex(event);
                    p1ID = MotionEventCompat.getPointerId(event, index);
                    if (p1ID != -1) {
                        int p1Index = MotionEventCompat.findPointerIndex(event, p1ID);
                        ((GameView.GameThread) mThread).checkTouch(MotionEventCompat.getX(event, p1Index),
                                MotionEventCompat.getY(event, p1Index));
                        //DO SOMETHING HERE

                    }
                } else if (!(mView.dialogOpen) && (!(((GameView.GameThread) mThread).gameOver))
                        && (((GameView.GameThread) mThread)
                                .getCurrentState() == GameView.GameThread.STATE_READY)
                        || (((GameView.GameThread) mThread)
                                .getCurrentState() == GameView.GameThread.STATE_LOSE)) {
                    ((GameView.GameThread) mThread).startGame();

                    // System.out.println("START GAME");

                } else if (((GameView.GameThread) mThread)
                        .getCurrentState() == GameView.GameThread.STATE_PAUSE) {
                    mThread.unpause();
                }

                return true;
            }
            case (MotionEvent.ACTION_MOVE): {
                //  System.out.println("ACTION_MOVE");
                if (((GameView.GameThread) mThread).getCurrentState() == GameView.GameThread.STATE_RUNNING) {
                    if (p1ID != -1) {
                        int p1Index = MotionEventCompat.findPointerIndex(event, p1ID);
                        //DO SOMETHING HERE

                    }
                }

                return true;
            }
            case (MotionEvent.ACTION_UP): {
                // System.out.println("ACTION_UP");

                reset();
                return true;
            }
            case (MotionEvent.ACTION_CANCEL): {
                // System.out.println("ACTION_CANCEL");
                reset();
                return true;
            }
            case (MotionEvent.ACTION_OUTSIDE): {
                return true;

            }
            }

            return false;
        }

        private void reset() {
            numTouches = 0;
            p1ID = -1;
            p2ID = -1;
        }
    }

    );
}

From source file:com.farmerbb.taskbar.activity.DashboardActivity.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_OUTSIDE)
        onBackPressed();// w  w w.  j a  v a 2  s.  c om
    return super.onTouchEvent(event);
}

From source file:com.limewoodmedia.nsdroid.fragments.NavigationDrawerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup layout = (ViewGroup) (inflater.inflate(R.layout.fragment_navigation_drawer, container, false));
    MenuItemHolder[] holders = new MenuItemHolder[] {
            new MenuItemHolder(R.id.menu_start, R.drawable.icon_start, R.string.menu_start),
            new MenuItemHolder(R.id.menu_nation, R.drawable.icon_nation, R.string.menu_nation),
            new MenuItemHolder(R.id.submenu_issues, R.drawable.icon_issues, R.string.menu_issues),
            new MenuItemHolder(R.id.submenu_dossier, R.drawable.icon_dossier, R.string.menu_dossier),
            new MenuItemHolder(R.id.menu_region, R.drawable.icon_region, R.string.menu_region),
            new MenuItemHolder(R.id.submenu_rmb, R.drawable.icon_rmb, R.string.menu_rmb),
            new MenuItemHolder(R.id.submenu_officers, R.drawable.icon_officers, R.string.menu_officers),
            new MenuItemHolder(R.id.submenu_embassies, R.drawable.icon_embassies, R.string.menu_embassies),
            new MenuItemHolder(R.id.menu_world, R.drawable.icon_world, R.string.menu_world),
            new MenuItemHolder(R.id.menu_wa, R.drawable.icon_wa, R.string.menu_wa),
            new MenuItemHolder(R.id.menu_news, R.drawable.icon_news, R.string.menu_news),
            new MenuItemHolder(R.id.menu_settings, R.drawable.icon_settings, R.string.menu_settings),
            new MenuItemHolder(R.id.menu_logout, R.drawable.icon_logout, R.string.menu_logout) };
    View view;//from   w  ww  .jav a 2  s  .c om
    for (final MenuItemHolder holder : holders) {
        view = layout.findViewById(holder.viewId);
        if (view == null)
            continue;
        ((ImageView) view.findViewById(R.id.menu_item_image)).setImageResource(holder.imageId);
        ((TextView) view.findViewById(R.id.menu_item_text)).setText(holder.textId);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                selectMenuItem(holder.viewId);
            }
        });
        view.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                switch (motionEvent.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    view.setBackgroundColor(getActivity().getResources().getColor(R.color.menu_item_selected));
                    break;
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_OUTSIDE:
                case MotionEvent.ACTION_CANCEL:
                case MotionEvent.ACTION_HOVER_EXIT:
                case MotionEvent.ACTION_POINTER_UP:
                    view.setBackgroundColor(0x00000000);
                    break;
                }
                return false;
            }
        });
    }
    //      layout.setOnTouchListener(new View.OnTouchListener() {
    //         @Override
    //         public boolean onTouch(View view, MotionEvent motionEvent) {
    //            return true;
    //         }
    //      });
    return layout;
}

From source file:com.adguard.android.commons.BrowserUtils.java

public static void showBrowserInstallDialog(final Context context) {
    // Touch listener for changing colors of CardViews
    View.OnTouchListener touchListener = new View.OnTouchListener() {
        @Override//  w w w  .j a v  a2 s.c om
        public boolean onTouch(View v, MotionEvent event) {
            int action = event.getActionMasked();
            if (action == MotionEvent.ACTION_DOWN) {
                ((CardView) v).setCardBackgroundColor(R.color.card_view_background_pressed);
            } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL
                    || action == MotionEvent.ACTION_OUTSIDE) {
                ((CardView) v).setCardBackgroundColor(R.color.white);
            }
            return false;
        }
    };

    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View dialogLayout = inflater.inflate(R.layout.select_browser_dialog, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialog);
    builder.setNegativeButton(android.R.string.cancel, null);
    builder.setView(dialogLayout);
    final AlertDialog dialog = builder.create();

    View cardView = dialogLayout.findViewById(R.id.browser_yandex);
    cardView.setOnTouchListener(touchListener);
    cardView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ActivityUtils.startMarket(context, YANDEX_BROWSER_PACKAGE, REFERRER);
            dialog.dismiss();
        }
    });

    cardView = dialogLayout.findViewById(R.id.browser_samsung);
    cardView.setOnTouchListener(touchListener);
    cardView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ActivityUtils.startMarket(context, SAMSUNG_BROWSER_PACKAGE, null);
            dialog.dismiss();
        }
    });

    dialog.show();
}