@OnTouch(R.id.crop_view) public boolean onTouchCropView(MotionEvent event) { // GitHub issue #4 if (event.getPointerCount() > 1 || cropView.getImageBitmap() == null) { return true; } switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_MOVE: ButterKnife.apply(buttons, VISIBILITY, View.INVISIBLE); break; default: ButterKnife.apply(buttons, VISIBILITY, View.VISIBLE); break; } return true; }
private static @Nullable Unbinder parseOnTouch(final Object target, final Method method, View source) { OnTouch onTouch = method.getAnnotation(OnTouch.class); if (onTouch == null) { return null; } validateMember(method); final boolean propagateReturn = validateReturnType(method, boolean.class); final ArgumentTransformer argumentTransformer = createArgumentTransformer(method, ON_TOUCH_TYPES); List<View> views = findViews(source, onTouch.value(), isRequired(method), method.getName(), View.class); ViewCollections.set(views, ON_TOUCH, (v, event) -> { Object returnValue = tryInvoke(method, target, argumentTransformer.transform(v)); //noinspection SimplifiableConditionalExpression return propagateReturn ? (boolean) returnValue : false; }); return new ListenerUnbinder<>(views, ON_TOUCH); }
@OnTouch(R.id.bt_button2) public boolean onTouch(View view, MotionEvent event){ Toast.makeText(this, "onTouch", Toast.LENGTH_SHORT).show(); return true; }
@OnTouch(value = {R.id.et_username, R.id.et_password}) public boolean onTouch(View v) { switch (v.getId()) { case R.id.et_username: lineUsername.setBackgroundColor(0xFF1F81F8); linePassword.setBackgroundColor(0xffaba7a7); break; case R.id.et_password: linePassword.setBackgroundColor(0xFF1F81F8); lineUsername.setBackgroundColor(0xffaba7a7); break; } return false; }
@SuppressWarnings("SameReturnValue") @OnTouch(R.id.viewpager_channels) public boolean onPagerTouch() { delayHide(); return false; }
@OnTouch(R.id.txt_new) boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { Drawable drawableRight = mTxtNew.getCompoundDrawables()[2]; if (drawableRight != null && event.getRawX() >= (mTxtNew.getRight() - drawableRight.getBounds().width())) { mTxtNew.setVisibility(View.GONE); return true; } } return false; } }
@OnTouch(R.id.bt_down) public boolean onDownButtonTouch(View view, MotionEvent event) { if (isActionDownMotionEvent(event)) { gameBoy.keyDown(Key.DOWN); } else if (isActionUpMotionEvent(event)) { gameBoy.keyUp(Key.DOWN); } return false; }
@OnTouch(R.id.bt_b) public boolean onBButtonTouch(View view, MotionEvent event) { if (isActionDownMotionEvent(event)) { gameBoy.keyDown(Key.B); } else if (isActionUpMotionEvent(event)) { gameBoy.keyUp(Key.B); } return false; }
@OnTouch(R.id.bt_start) public boolean onStartButtonTouch(View view, MotionEvent event) { if (isActionDownMotionEvent(event)) { gameBoy.keyDown(Key.START); } else if (isActionUpMotionEvent(event)) { gameBoy.keyUp(Key.START); } return false; }
@OnTouch(R.id.bt_right) public boolean onRightButtonTouch(View view, MotionEvent event) { if (isActionDownMotionEvent(event)) { gameBoy.keyDown(Key.RIGHT); } else if (isActionUpMotionEvent(event)) { gameBoy.keyUp(Key.RIGHT); } return false; }
@OnTouch(R.id.bt_select) public boolean onSelectButtonTouch(View view, MotionEvent event) { if (isActionDownMotionEvent(event)) { gameBoy.keyDown(Key.SELECT); } else if (isActionUpMotionEvent(event)) { gameBoy.keyUp(Key.SELECT); } return false; }
@OnTouch(R.id.bt_a) public boolean onAButtonTouch(View view, MotionEvent event) { if (isActionDownMotionEvent(event)) { gameBoy.keyDown(Key.A); } else if (isActionUpMotionEvent(event)) { gameBoy.keyUp(Key.A); } return false; }
@OnTouch(R.id.bt_up) public boolean onUpButtonTouch(View view, MotionEvent event) { if (isActionDownMotionEvent(event)) { gameBoy.keyDown(Key.UP); } else if (isActionUpMotionEvent(event)) { gameBoy.keyUp(Key.UP); } return false; }
@OnTouch(R.id.bt_left) public boolean onLeftButtonTouch(View view, MotionEvent event) { if (isActionDownMotionEvent(event)) { gameBoy.keyDown(Key.LEFT); } else if (isActionUpMotionEvent(event)) { gameBoy.keyUp(Key.LEFT); } return false; }