Java Code Examples for android.view.View#performClick()

The following examples show how to use android.view.View#performClick() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: aurora-imui   File: MessageListActivity.java    License: MIT License 6 votes vote down vote up
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    switch (motionEvent.getAction()) {
        case MotionEvent.ACTION_DOWN:
            ChatInputView chatInputView = mChatView.getChatInputView();
            if (chatInputView.getMenuState() == View.VISIBLE) {
                chatInputView.dismissMenuLayout();
            }
            mChatView.setMsgListHeight(true);
            try {
                View v = getCurrentFocus();
                if (mImm != null && v != null) {
                    mImm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                    mWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
                    view.clearFocus();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            break;
        case MotionEvent.ACTION_UP:
            view.performClick();
            break;
    }
    return false;
}
 
Example 2
public static ViewAction clickChildViewWithId(final int id) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return null;
        }

        @Override
        public String getDescription() {
            return null;
        }

        @Override
        public void perform(UiController uiController, View view) {
            View v = view.findViewById(id);
            v.performClick();
        }
    };
}
 
Example 3
Source Project: AndroidBottomSheet   File: BottomSheet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates and returns a listener, which allows to cancel the bottom sheet, when the decor view
 * is touched.
 *
 * @return The listener, which has been created, as an instance of the type {@link
 * View.OnTouchListener}
 */
private View.OnTouchListener createCancelOnTouchListener() {
    return new View.OnTouchListener() {

        @Override
        public boolean onTouch(final View v, final MotionEvent event) {
            if (cancelable && canceledOnTouchOutside) {
                cancel();
                v.performClick();
                return true;
            }

            return false;
        }

    };
}
 
Example 4
/**
 * Clicks the Next button.
 */
public static ViewAction clickNext() {
    return new AbstractStepperNavigationAction() {

        @Override
        public String getDescription() {
            return "Click on the Next button";
        }

        @Override
        protected void performAction(StepperLayout stepperLayout) {
            View nextButton = stepperLayout.findViewById(com.stepstone.stepper.R.id.ms_stepNextButton);
            nextButton.performClick();
        }

    };
}
 
Example 5
/**
 * Clicks the Complete button.
 */
public static ViewAction clickComplete() {
    return new AbstractStepperNavigationAction() {

        @Override
        public String getDescription() {
            return "Click on the Complete button";
        }

        @Override
        protected void performAction(StepperLayout stepperLayout) {
            View completeButton = stepperLayout.findViewById(com.stepstone.stepper.R.id.ms_stepCompleteButton);
            completeButton.performClick();
        }

    };
}
 
Example 6
Source Project: xposed-rimet   File: BaseHandler.java    License: Apache License 2.0 5 votes vote down vote up
public void performClick(View view) {

        if (view != null && view.isShown()) {
            // 点击
            view.performClick();
        }
    }
 
Example 7
Source Project: xposed-rimet   File: DingDingHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onHandlerFestivalRedPacketsPick(Activity activity) {

    if (!mEnableFastLucky) return;

    View view = activity.findViewById(ResourceUtil.getId(activity, getXString(M.res.res_iv_pick)));
    if (view != null && view.isClickable()) view.performClick();
}
 
Example 8
Source Project: xposed-rimet   File: DingDingHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onHandlerPickRedPackets(Activity activity) {

    if (!mEnableFastLucky) return;

    View view = activity.findViewById(ResourceUtil.getId(activity, getXString(M.res.res_btn_pick)));
    if (view != null && view.isClickable()) view.performClick();
}
 
Example 9
@Override
public void devModel() {
    if(DevToolsAct.DEV_AUTO_ANSWER){

        for (int i = 0; i < mGiftModel.choose.size(); i++) {
            AnswerModel bean=mGiftModel.choose.get(i);
            if(bean.result){
                View v=mRecycler.getChildAt(i);
                v.performClick();
            }
        }
        ((StudyAct) getActivity()).next(DevToolsAct.DEV_AUTO_ANSWER?100:500);
    }
}
 
Example 10
@Override
public boolean onTouch(View v, MotionEvent event) {
    if (v == videosFoundHUD) {
        gesture.onTouchEvent(event);

        switch (event.getAction()) {
            case MotionEvent.ACTION_UP:
                if (!moved) v.performClick();
                moved = false;
                break;
            case MotionEvent.ACTION_DOWN:
                prevX = event.getRawX();
                prevY = event.getRawY();
                break;
            case MotionEvent.ACTION_MOVE:
                moved = true;
                float moveX = event.getRawX() - prevX;
                videosFoundHUD.setX(videosFoundHUD.getX() + moveX);
                prevX = event.getRawX();
                float moveY = event.getRawY() - prevY;
                videosFoundHUD.setY(videosFoundHUD.getY() + moveY);
                prevY = event.getRawY();
                float width = getResources().getDisplayMetrics().widthPixels;
                float height = getResources().getDisplayMetrics().heightPixels;
                if ((videosFoundHUD.getX() + videosFoundHUD.getWidth()) >= width
                        || videosFoundHUD.getX() <= 0) {
                    videosFoundHUD.setX(videosFoundHUD.getX() - moveX);
                }
                if ((videosFoundHUD.getY() + videosFoundHUD.getHeight()) >= height
                        || videosFoundHUD.getY() <= 0) {
                    videosFoundHUD.setY(videosFoundHUD.getY() - moveY);
                }
                break;
        }
    }
    return true;
}
 
Example 11
Source Project: FantasySlide   File: SideBar.java    License: Apache License 2.0 5 votes vote down vote up
void onMotionEventUp() {
    for (int i = 0; opened && i < getChildCount(); i++) {
        View child = getChildAt(i);
        if (child.isPressed()) {
            if (fantasyListener == null || !fantasyListener.onSelect(child, i)) {
                child.performClick();
            }
            return;
        }
    }
    if (fantasyListener != null) {
        fantasyListener.onCancel();
    }
}
 
Example 12
@Test
public void singleSelection_withSelectionRequired_doesNotUnSelect() {
  chipgroup.setSelectionRequired(true);
  chipgroup.setSingleSelection(true);

  View chip = chipgroup.getChildAt(0);
  chip.performClick();
  chip.performClick();

  assertThat(((Chip) chip).isChecked()).isTrue();
}
 
Example 13
Source Project: ToDay   File: MainActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    mCoordinator.restoreState(savedInstanceState);
    if (savedInstanceState.getBoolean(STATE_TOOLBAR_TOGGLE, false)) {
        View toggleButton = findViewById(R.id.toolbar_toggle_frame);
        if (toggleButton != null) { // can be null as disabled in landscape
            toggleButton.performClick();
        }
    }
}
 
Example 14
private void performClickOnButton(int btnResourceId, final RecordingButtonInterface mockBtnInterface) {
    final VideoCaptureView videoCaptureView = new VideoCaptureView(InstrumentationRegistry.getTargetContext());
    videoCaptureView.setRecordingButtonInterface(mockBtnInterface);
    final View btn = videoCaptureView.findViewById(btnResourceId);
    btn.performClick();
}
 
Example 15
Source Project: clickguard   File: ClickGuardTest.java    License: Apache License 2.0 4 votes vote down vote up
private static void clickView(View view, int count) {
    for (int i = 0; i < count; i++) {
        view.performClick();
    }
}
 
Example 16
/**
	 * View#onTouchEventの処理
	 * falseを返したときにはView#super.onTouchEventでデフォルトの処理をすること
	 * @param event
	 * @return
	 */
	@SuppressLint("SwitchIntDef")
	public boolean onTouchEvent(final MotionEvent event) {
//		if (DEBUG) Log.v(TAG, "onTouchEvent:");

		if (mHandleTouchEvent == TOUCH_DISABLED) {
			return false;
		}

		final View view = getTargetView();
		final int actionCode = event.getActionMasked();	// >= API8

		switch (actionCode) {
		case MotionEvent.ACTION_DOWN:
			// single touch
			startWaiting(event);
			return true;
		case MotionEvent.ACTION_POINTER_DOWN:
		{	// マルチタッチ時の処理
			switch (mState) {
			case STATE_WAITING:
				// 最初のマルチタッチ → 拡大縮小・回転操作待機開始
				view.removeCallbacks(mWaitImageReset);
				// pass through
			case STATE_DRAGGING:
				if (event.getPointerCount() > 1) {
					startCheck(event);
					return true;
				}
				break;
			}
			break;
		}
		case MotionEvent.ACTION_MOVE:
		{
			// moving with single and multi touch
			switch (mState) {
			case STATE_WAITING:
				if (((mHandleTouchEvent & TOUCH_ENABLED_MOVE) == TOUCH_ENABLED_MOVE)
					&& checkTouchMoved(event)) {

					view.removeCallbacks(mWaitImageReset);
					setState(STATE_DRAGGING);
					return true;
				}
				break;
			case STATE_DRAGGING:
				if (processDrag(event))
					return true;
				break;
			case STATE_CHECKING:
				if (checkTouchMoved(event)
					&& ((mHandleTouchEvent & TOUCH_ENABLED_ZOOM) == TOUCH_ENABLED_ZOOM)) {

					startZoom(event);
					return true;
				}
				break;
			case STATE_ZOOMING:
				if (processZoom(event))
					return true;
				break;
			case STATE_ROTATING:
				if (processRotate(event))
					return true;
				break;
			}
			break;
		}
		case MotionEvent.ACTION_CANCEL:
			// pass through
		case MotionEvent.ACTION_UP:
			view.removeCallbacks(mWaitImageReset);
			view.removeCallbacks(mStartCheckRotate);
			if ((actionCode == MotionEvent.ACTION_UP) && (mState == STATE_WAITING)) {
				final long downTime = SystemClock.uptimeMillis() - event.getDownTime();
				if (downTime > LONG_PRESS_TIMEOUT) {
					view.performLongClick();
				} else if (downTime < TAP_TIMEOUT) {
					view.performClick();
				}
			}
			// pass through
		case MotionEvent.ACTION_POINTER_UP:
			setState(STATE_NON);
			break;
		}
		return false;
	}
 
Example 17
Source Project: letv   File: CashierAcitivity.java    License: Apache License 2.0 4 votes vote down vote up
private View inflaterOthersView() {
    final View othersView = View.inflate(this.context, ResourceUtil.getLayoutResource(this.context, "lepay_cashier_paychannel_other"), null);
    ImageView itemIcon = (ImageView) othersView.findViewById(ResourceUtil.getIdResource(this.context, "lepay_paychannel_item_icon"));
    TextView itemTitle = (TextView) othersView.findViewById(ResourceUtil.getIdResource(this.context, "lepay_paychannel_item_title"));
    final ImageView arrawicon = (ImageView) othersView.findViewById(ResourceUtil.getIdResource(this.context, "lepay_cashier_paytype_other_selector_icon"));
    arrawicon.setImageResource(ResourceUtil.getDrawableResource(this.context, "icon_down"));
    itemIcon.setImageResource(ResourceUtil.getDrawableResource(this.context, "lepay_icon_more"));
    itemTitle.setText(ResourceUtil.getStringResource(this.context, "lepay_ohters_paytype"));
    othersView.setTag(Boolean.FALSE);
    othersView.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            int count;
            int i;
            if (((Boolean) view.getTag()).booleanValue()) {
                arrawicon.setImageResource(ResourceUtil.getDrawableResource(CashierAcitivity.this.context, "icon_down"));
                count = CashierAcitivity.this.lepay_cashier_paytype_list.getChildCount();
                for (i = 0; i < count; i++) {
                    View v = CashierAcitivity.this.lepay_cashier_paytype_list.getChildAt(i);
                    CheckBox checkBox = (CheckBox) v.findViewById(ResourceUtil.getIdResource(CashierAcitivity.this, "lepay_paychannel_item_checkbox"));
                    if (checkBox != null) {
                        if (((Boolean) checkBox.getTag()).booleanValue()) {
                            v.setVisibility(8);
                        } else {
                            v.setVisibility(0);
                        }
                    }
                }
                othersView.setTag(Boolean.FALSE);
                return;
            }
            arrawicon.setImageResource(ResourceUtil.getDrawableResource(CashierAcitivity.this.context, "icon_up"));
            count = CashierAcitivity.this.lepay_cashier_paytype_list.getChildCount();
            for (i = 0; i < count; i++) {
                CashierAcitivity.this.lepay_cashier_paytype_list.getChildAt(i).setVisibility(0);
            }
            othersView.setTag(Boolean.TRUE);
        }
    });
    othersView.performClick();
    othersView.performClick();
    return othersView;
}
 
Example 18
private void performClickOnButton(int btnResourceId, final RecordingButtonInterface mockBtnInterface) {
    final VideoCaptureView videoCaptureView = new VideoCaptureView(InstrumentationRegistry.getTargetContext());
    videoCaptureView.setRecordingButtonInterface(mockBtnInterface);
    final View btn = videoCaptureView.findViewById(btnResourceId);
    btn.performClick();
}
 
Example 19
@Override
public void onClick(View v) {
	if(v == actionToggle) {
		switch(state) {
		case RecorderState.IS_IDLE:
			if(progress.rawAudioData == null) {
				// record
				progress.record();
				setState(RecorderState.IS_RECORDING);
			} else {
				if(state != RecorderState.IS_IDLE) {
					if(state == RecorderState.IS_RECORDING) {
						progress.stop();
					} else if(state == RecorderState.IS_PLAYING) {
						progress.pause();
					}
					setState(RecorderState.IS_IDLE);
				}
				
				res = pauseRes;
				
				progress.play();
				setState(RecorderState.IS_PLAYING);
			}
			
			break;
		case RecorderState.IS_RECORDING:
			progress.stop();
			setState(RecorderState.IS_IDLE);
			
			res = recordRes;
			
			form.answer(Forms.FreeAudio.PROMPT);
			break;
		case RecorderState.IS_PLAYING:
			
			res = recordRes;
			
			progress.pause();
			setState(RecorderState.IS_IDLE);
			v.performClick();
			break;
		}
	} else if(v == actionDone) {
		if(state == RecorderState.IS_PLAYING) {
			progress.pause();
		} else if(state == RecorderState.IS_RECORDING) {
			progress.stop();
		}
		setState(RecorderState.IS_IDLE);
		
		form.answer(Forms.FreeAudio.PROMPT);
		cancel();
		return;
	} else if(v == actionRedo) {
		if(state == RecorderState.IS_PLAYING) {
			progress.pause();
		} else if(state == RecorderState.IS_RECORDING) {
			progress.stop();
		}
		
		form.getQuestionDefByTitleId(Forms.FreeAudio.PROMPT).clear();
		progress.reInit(new java.io.File(Storage.EXTERNAL_DIR, "tmprecord_" + System.currentTimeMillis() + ".3gp"), this);
		updateLayout(false);
		return;
	}
	
	updateLayout();
}
 
Example 20
/**
 * Clicks on given {@link View}.
 * 
 * @param buttonId
 *            the button id
 */
public void click(final int buttonId) {
	final View view = get(buttonId);
	view.performClick();
}