下面列出了android.view.View#sendAccessibilityEvent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private boolean performPinnedItemClick() {
if (mPinnedSection == null) {
return false;
}
OnItemClickListener listener = getOnItemClickListener();
if (listener != null && getAdapter().isEnabled(mPinnedSection.position)) {
View view = mPinnedSection.view;
playSoundEffect(SoundEffectConstants.CLICK);
if (view != null) {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
}
listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
return true;
}
return false;
}
void dispatchOnDrawerClosed(View drawerView) {
final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
if (lp.knownOpen) {
lp.knownOpen = false;
if (mListener != null) {
mListener.onDrawerClosed(drawerView);
}
updateChildrenImportantForAccessibility(drawerView, false);
// Only send WINDOW_STATE_CHANGE if the host has window focus. This
// may change if support for multiple foreground windows (e.g. IME)
// improves.
if (hasWindowFocus()) {
final View rootView = getRootView();
if (rootView != null) {
rootView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
}
}
}
private void dispatchOnDrawerClosed(View drawerView) {
if ((openState & FLAG_IS_OPENED) == FLAG_IS_OPENED) {
openState = 0;
updateChildrenImportantForAccessibility(drawerView, false);
// Only send WINDOW_STATE_CHANGE if the host has window focus. This
// may change if support for multiple foreground windows (e.g. IME)
// improves.
if (parent.hasWindowFocus()) {
final View rootView = parent.getRootView();
if (rootView != null) {
rootView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
}
}
}
public boolean performHeaderClick(View view, long id) {
if (mOnHeaderClickListener != null) {
playSoundEffect(SoundEffectConstants.CLICK);
if (view != null) {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
}
mOnHeaderClickListener.onHeaderClick(this, view, id);
return true;
}
return false;
}
/**
* Call the OnItemClickListener, if it is defined.
*
* @param view The view within the AdapterView that was clicked.
* @param position The position of the view in the adapter.
* @param id The row id of the item that was clicked.
* @return True if there was an assigned OnItemClickListener that was
* called, false otherwise is returned.
*/
public boolean performItemClick(View view, int position, long id) {
if (mOnItemClickListener != null) {
playSoundEffect(SoundEffectConstants.CLICK);
if (view != null) {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
}
mOnItemClickListener.onItemClick(/*this*/null, view, position, id);
return true;
}
return false;
}
void setStateInternal(@State int state) {
int previousState = this.state;
if (this.state == state) {
return;
}
this.state = state;
if (viewRef == null) {
return;
}
View bottomSheet = viewRef.get();
if (bottomSheet == null) {
return;
}
if (state == STATE_HALF_EXPANDED || state == STATE_EXPANDED) {
updateImportantForAccessibility(true);
} else if (state == STATE_HIDDEN || state == STATE_COLLAPSED) {
updateImportantForAccessibility(false);
}
ViewCompat.setImportantForAccessibility(
bottomSheet, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
bottomSheet.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
updateDrawableOnStateChange(state, previousState);
if (callback != null) {
callback.onStateChanged(bottomSheet, state);
}
}
public boolean performHeaderClick(View view, long id) {
if (mOnHeaderClickListener != null) {
playSoundEffect(SoundEffectConstants.CLICK);
if (view != null) {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
}
mOnHeaderClickListener.onHeaderClick(this, view, id);
return true;
}
return false;
}
public boolean performHeaderLongPress(View view, long id) {
boolean handled = false;
if (mOnHeaderLongClickListener != null) {
handled = mOnHeaderLongClickListener.onHeaderLongClick(this, view, id);
}
if (handled) {
if (view != null) {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
}
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
return handled;
}
private boolean performPinnedItemClick() {
if (mPinnedSection == null) return false;
OnItemClickListener listener = getOnItemClickListener();
if (listener != null && getAdapter().isEnabled(mPinnedSection.position)) {
View view = mPinnedSection.view;
playSoundEffect(SoundEffectConstants.CLICK);
if (view != null) {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
}
listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
return true;
}
return false;
}
private boolean performPinnedItemClick() {
if (mPinnedSection == null) return false;
OnItemClickListener listener = getOnItemClickListener();
if (listener != null) {
View view = mPinnedSection.view;
playSoundEffect(SoundEffectConstants.CLICK);
if (view != null) {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
}
listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
return true;
}
return false;
}
void dispatchOnDrawerOpened(View drawerView) {
final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
if (!lp.knownOpen) {
lp.knownOpen = true;
if (mListener != null) {
mListener.onDrawerOpened(drawerView);
}
drawerView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
}
private void setInitialFocus() {
InputMethodManager imm = (InputMethodManager) mDialog.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
View view = mShouldRequestExpirationDate ? mMonthInput : mCardUnmaskInput;
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
if (sObserverForTest != null) {
sObserverForTest.onCardUnmaskPromptReadyForInput(this);
}
}
/**
* Call the OnItemClickListener, if it is defined.
*
* @param view The view within the AdapterView that was clicked.
* @param position The position of the view in the adapter.
* @param id The row id of the item that was clicked.
* @return True if there was an assigned OnItemClickListener that was
* called, false otherwise is returned.
*/
public boolean performItemClick(View view, int position, long id) {
if (mOnItemClickListener != null) {
playSoundEffect(SoundEffectConstants.CLICK);
if (view != null) {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
}
mOnItemClickListener.onItemClick(/*this*/null, view, position, id);
return true;
}
return false;
}
void dispatchOnDrawerOpened(View drawerView) {
final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
if (!lp.knownOpen) {
lp.knownOpen = true;
if (mListener != null) {
mListener.onDrawerOpened(drawerView);
}
drawerView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
}
private void setInitialFocus() {
InputMethodManager imm = (InputMethodManager) mDialog.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
View view = mShouldRequestExpirationDate ? mMonthInput : mCardUnmaskInput;
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
if (sObserverForTest != null) {
sObserverForTest.onCardUnmaskPromptReadyForInput(this);
}
}
private void setInitialFocus() {
InputMethodManager imm = (InputMethodManager) mDialog.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
View view = mShouldRequestExpirationDate ? mMonthInput : mCardUnmaskInput;
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
if (sObserverForTest != null) {
sObserverForTest.onCardUnmaskPromptReadyForInput(this);
}
}
void dispatchOnDrawerOpened(View drawerView) {
final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
if (!lp.knownOpen) {
lp.knownOpen = true;
if (mListener != null) {
mListener.onDrawerOpened(drawerView);
}
drawerView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
}
private boolean performPinnedItemClick() {
if (mPinnedSection == null) return false;
OnItemClickListener listener = getOnItemClickListener();
if (listener != null) {
View view = mPinnedSection.view;
playSoundEffect(SoundEffectConstants.CLICK);
if (view != null) {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
}
listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
return true;
}
return false;
}
/**
* Call the OnItemClickListener, if it is defined. Performs all normal
* actions associated with clicking: reporting accessibility event, playing
* a sound, etc.
*
* @param view The view within the AdapterView that was clicked.
* @param position The position of the view in the adapter.
* @param id The row id of the item that was clicked.
* @return True if there was an assigned OnItemClickListener that was
* called, false otherwise is returned.
*/
public boolean superPerformItemClick(View view, int position, long id) {
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(this, view, position, id);
if (view != null) {
view.playSoundEffect(SoundEffectConstants.CLICK);
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
}
return true;
}
return false;
}
/**
* Call the OnItemClickListener, if it is defined. Performs all normal
* actions associated with clicking: reporting accessibility event, playing
* a sound, etc.
*
* @param view
* The view within the AdapterView that was clicked.
* @param position
* The position of the view in the adapter.
* @param id
* The row id of the item that was clicked.
* @return True if there was an assigned OnItemClickListener that was
* called, false otherwise is returned.
*/
public boolean performItemClick(View view, int sectionIndex, int positionInSection, long id) {
if (mOnItemClickListener != null) {
// playSoundEffect(SoundEffectConstants.CLICK);
if (view != null) {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
}
mOnItemClickListener.onItemClick(this, getFreeFlowItemForVisibleItemAt(sectionIndex, positionInSection));
return true;
}
return false;
}