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

The following are Jave code examples for showing how to use performClick() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: fullscreen-video-view   File: CustomChecks.java   Source Code and License Vote up 7 votes
static ViewAction clickNoConstraints() {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isEnabled(); // No constraints, isEnabled and isClickable are checked
        }

        @Override
        public String getDescription() {
            return "Click a view with no constraints.";
        }

        @Override
        public void perform(UiController uiController, View view) {
            view.performClick();
        }
    };
}
 
Example 2
Project: starwarsshop   File: MyViewAction.java   Source Code and License Vote up 7 votes
public static ViewAction clickChildViewWithId(final int id) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return null;
        }

        @Override
        public String getDescription() {
            return "Click on a child view with specified id.";
        }

        @Override
        public void perform(UiController uiController, View view) {
            View v = view.findViewById(id);
            v.performClick();
        }
    };
}
 
Example 3
Project: Matrix-Calculator-for-Android   File: faqs.java   Source Code and License Vote up 7 votes
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    switch (motionEvent.getAction()) {
        case MotionEvent.ACTION_DOWN:
            ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationZ", 20);
            animator.setDuration(200);
            animator.setInterpolator(new DecelerateInterpolator());
            animator.start();
            view.performClick();
            return true;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "translationZ", 0);
            animator2.setDuration(200);
            animator2.setInterpolator(new AccelerateInterpolator());
            animator2.start();
            return true;
        default:
            return false;
    }
}
 
Example 4
Project: emerald   File: SwipeListener.java   Source Code and License Vote up 7 votes
@Override
public boolean onTouch(View v, MotionEvent e) {
	int action = e.getAction() & 255;
	switch (action){
		case MotionEvent.ACTION_DOWN:
			x = e.getX();
			return true;
		case MotionEvent.ACTION_UP:
			if (e.getX()-x > 30.0 * density) {
				LauncherApp.getInstance().getCategoryManager().setCurCategory(LauncherApp.getInstance().getCategoryManager().getPrevCategory());
				appsRef.get().loadFilteredApps();
				appsRef.get().setSpinner();
				return true;
			} else if (x-e.getX() > 30.0 * density) {
				LauncherApp.getInstance().getCategoryManager().setCurCategory(LauncherApp.getInstance().getCategoryManager().getNextCategory());
				appsRef.get().loadFilteredApps();
				appsRef.get().setSpinner();
				return true;
			} else v.performClick();
		default:
			return false;
	}
}
 
Example 5
Project: FinalProject   File: MessagesListAdapter.java   Source Code and License Vote up 7 votes
private View.OnLongClickListener getMessageLongClickListener(final Wrapper<MESSAGE> wrapper) {
    return new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            if (selectionListener == null) {
                notifyMessageLongClicked(wrapper.item);
                notifyMessageViewLongClicked(view, wrapper.item);
                return true;
            } else {
                isSelectionModeEnabled = true;
                view.performClick();
                return true;
            }
        }
    };
}
 
Example 6
Project: GitHub   File: SimpleOnTouchListener.java   Source Code and License Vote up 6 votes
@Override
public boolean onTouch(final View view, MotionEvent event) {
	if (event.getAction() == MotionEvent.ACTION_UP) {
		view.requestFocus();
		//MyApplication.hideSoftInputFrom(context, view);
		view.performClick();
	}
	return true;
}
 
Example 7
Project: airgram   File: ScrollSlidingTabStrip.java   Source Code and License Vote up 6 votes
public void selectTab(int num) {
    if (num < 0 || num >= tabCount) {
        return;
    }
    View tab = tabsContainer.getChildAt(num);
    if (Build.VERSION.SDK_INT >= 15) {
        tab.callOnClick();
    } else {
        tab.performClick();
    }
}
 
Example 8
Project: Phial   File: DragHelper.java   Source Code and License Vote up 6 votes
private boolean onTouch(View v, MotionEvent event) {
    if (parent.isEmpty()) {
        return false;
    }

    animator.cancel();

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            initialTouchX = event.getRawX();
            initialTouchY = event.getRawY();
            startTimeMS = event.getEventTime();
            onMoveStart(v);
            v.setPressed(true);
            return true;
        case MotionEvent.ACTION_MOVE:
            animator.cancel();
            onMove(v, event.getRawX() - initialTouchX, event.getRawY() - initialTouchY);
            return true;
        case MotionEvent.ACTION_UP:
            v.setPressed(false);
            onMoveEnd(v);
            final long downTimeMS = event.getEventTime() - startTimeMS;
            final float halfButtonSize = Math.min(v.getHeight(), v.getWidth()) / 2f;
            final boolean wasClicked = downTimeMS < CLICK_MAX_DURATION_MS
                    && ViewUtil.distance(initialTouchX, initialTouchY, event.getRawX(), event.getRawY()) < halfButtonSize;
            if (wasClicked) {
                v.performClick();
            }
            return true;
        default:
            return true;
    }
}
 
Example 9
Project: AndroidBlueprints   File: SimpleOnTouchListener.java   Source Code and License Vote up 6 votes
@Override
public boolean onTouch(final View view, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_UP) {
        view.requestFocus();
        Utils.hideSoftInputFrom(context, view);
        view.performClick();
    }
    return true;
}
 
Example 10
Project: Slide-RSS   File: FeedAdapter.java   Source Code and License Vote up 6 votes
public void performClick(int adapterPosition) {
    if (listView != null) {
        RecyclerView.ViewHolder holder =
                listView.findViewHolderForLayoutPosition(adapterPosition);
        if (holder != null) {
            View view = holder.itemView;
            if (view != null) {
                view.performClick();
            }
        }
    }
}
 
Example 11
Project: PlusGram   File: ScrollSlidingTabStrip.java   Source Code and License Vote up 6 votes
public void selectTab(int num) {
    if (num < 0 || num >= tabCount) {
        return;
    }
    View tab = tabsContainer.getChildAt(num);
    if (Build.VERSION.SDK_INT >= 15) {
        tab.callOnClick();
    } else {
        tab.performClick();
    }
}
 
Example 12
Project: fullscreen-video-view   File: FullscreenVideoView.java   Source Code and License Vote up 5 votes
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    view.performClick();
    controller.show();
    return false;
}
 
Example 13
Project: TripleTap   File: MultiplayerGameFragmentAndroidTests.java   Source Code and License Vote up 5 votes
@Override
public void perform(UiController uiController, View view) {
    view.performClick();
}
 
Example 14
Project: TripleTap   File: NormalGameFragmentAndroidTests.java   Source Code and License Vote up 5 votes
@Override
public void perform(UiController uiController, View view) {
    view.performClick();
}
 
Example 15
Project: androidadvanced   File: ShadowRecyclerViewAdapter.java   Source Code and License Vote up 5 votes
public boolean performItemClick(int position){
    View holderView = holders.get(position).itemView;
    return holderView.performClick();
}
 
Example 16
Project: RLibrary   File: RBaseViewHolder.java   Source Code and License Vote up 5 votes
/**
 * 单击某个View
 */
public void clickView(View view) {
    if (view != null) {
        view.performClick();
    }
}
 
Example 17
Project: letv   File: CashierAcitivity.java   Source Code and License Vote up 5 votes
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
Project: buildAPKsApps   File: AppLockActivity.java   Source Code and License Vote up 5 votes
@Override
public boolean onTouch(View v, MotionEvent event) {
	v.performClick();
	clearFields();
	return false;
}
 
Example 19
Project: AppLocker   File: LockActivity.java   Source Code and License Vote up 5 votes
@Override
public boolean onTouch(View v, MotionEvent event) {
	v.performClick();
	clearFields();
	return false;
}
 
Example 20
Project: KotlinStudy   File: VocalVerifyDemo.java   Source Code and License Vote up 5 votes
@Override
public boolean onTouch(View v, MotionEvent event) {
	if( !checkInstance() ){
		return false;
	}
	switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			authid = getAuthid();
			if(TextUtils.isEmpty(authid)) {
				showTip("请输入authid");
				break;
			}
			if (!isStartWork) {
				// 根据业务类型调用服务
				if (mSST == SST_ENROLL) {
					if (null == mNumPwdSegs) {
						// 启动录音机时密码为空,中断此次操作,下载密码
						downloadPwd();
						break;
					}
					vocalEnroll();
				} else if (mSST == SST_VERIFY) {
					vocalVerify();
				} else {
					showTip("请先选择相应业务!");
					break;
				}
				isStartWork = true;
				mCanStartRecord = true;
			}
			if (mCanStartRecord) {
				try {
					mPcmRecorder = new PcmRecorder(SAMPLE_RATE, 40);
					mPcmRecorder.startRecording(mPcmRecordListener);
				} catch (SpeechError e) {
					e.printStackTrace();
				}
			}
			break;
		case MotionEvent.ACTION_UP:
			v.performClick();

			mIdVerifier.stopWrite("ivp");
			if (null != mPcmRecorder) {

				mPcmRecorder.stopRecord(true);
			}
			break;

		default:
			break;
	}
	return false;
}