本文整理汇总了Java中android.view.accessibility.AccessibilityEvent类的典型用法代码示例。如果您正苦于以下问题:Java AccessibilityEvent类的具体用法?Java AccessibilityEvent怎么用?Java AccessibilityEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AccessibilityEvent类属于android.view.accessibility包,在下文中一共展示了AccessibilityEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
int eventType = event.getEventType();
switch (eventType) {
case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:
for (String id : installBtnId) {
AccessibilityNodeInfo node = AccessibilityNodeUtil.findNodeById(event.getSource(), id);
if (node != null) {
AccessibilityNodeUtil.click(node);
Toast.makeText(this, "安装成功", Toast.LENGTH_SHORT).show();
break;
}
}
break;
default:
break;
}
}
示例2: updateAccessibilityVisibility
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
/**
* Update whether or not the current native tab and/or web contents are
* currently visible (from an accessibility perspective), or whether
* they're obscured by another view.
*/
public void updateAccessibilityVisibility() {
View view = getView();
if (view != null) {
int importantForAccessibility = isObscuredByAnotherViewForAccessibility()
? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
: View.IMPORTANT_FOR_ACCESSIBILITY_YES;
if (view.getImportantForAccessibility() != importantForAccessibility) {
view.setImportantForAccessibility(importantForAccessibility);
view.sendAccessibilityEvent(
AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
}
}
ContentViewCore cvc = getContentViewCore();
if (cvc != null) {
boolean isWebContentObscured = isObscuredByAnotherViewForAccessibility()
|| isShowingSadTab();
cvc.setObscuredByAnotherView(isWebContentObscured);
}
}
示例3: dispatchPopulateAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
boolean populated = false;
if (event.getEventType() == 8) {
event.setEventType(4);
}
View selectedView = getSelectedView();
if (selectedView != null) {
populated = selectedView.dispatchPopulateAccessibilityEvent(event);
}
if (!populated) {
if (selectedView != null) {
event.setEnabled(selectedView.isEnabled());
}
event.setItemCount(getCount());
event.setCurrentItemIndex(getSelectedItemPosition());
}
return populated;
}
示例4: setCurrentActivityName
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
private void setCurrentActivityName(AccessibilityEvent event) {
if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
return;
}
try {
ComponentName componentName = new ComponentName(
event.getPackageName().toString(),
event.getClassName().toString()
);
getPackageManager().getActivityInfo(componentName, 0);
currentActivityName = componentName.flattenToShortString();
} catch (PackageManager.NameNotFoundException e) {
currentActivityName = WECHAT_LUCKMONEY_GENERAL_ACTIVITY;
}
}
示例5: dispatchPopulateAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
// Dispatch scroll events from this ViewPager.
if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
return super.dispatchPopulateAccessibilityEvent(event);
}
// Dispatch all other accessibility events from the current page.
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == VISIBLE) {
final YViewPagerNew.ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == mCurItem
&& child.dispatchPopulateAccessibilityEvent(event)) {
return true;
}
}
}
return false;
}
示例6: contentChange
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
/**
* 内容改变
*
* @param event
*/
private void contentChange(AccessibilityEvent event) {
AccessibilityNodeInfo root = getRootInActiveWindow();
if (root == null) {
return;
}
if (WechatVersionUtils.canFindViewById(context) && WechatVersionUtils.canRobWechatVersion(context)) {
List<AccessibilityNodeInfo> exitNodeInfos = root.findAccessibilityNodeInfosByViewId(WechatVersionUtils.getWechatExitId(context));
if (exitNodeInfos != null && exitNodeInfos.size() > 0) {
// 是聊天界面
if (isWechatAlway) {
}
} else {
isWechatAlway = false;
}
}
}
示例7: autoChat
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
public void autoChat(AccessibilityEvent event, AccessibilityNodeInfo node,WeixinAutoService context,Map<String,String> record){
int eventType = event.getEventType();
//1、消息列表获取信息头像
List<AccessibilityNodeInfo> msgNumImages= node.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/i4");
if(msgNumImages!=null&&msgNumImages.size()>0){
AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(context.getRootInActiveWindow(),"com.tencent.mm:id/afv","杰"),record,"杰",1000);
sendMsg(context.getRootInActiveWindow(),context,record);
AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(context.getRootInActiveWindow(),"com.tencent.mm:id/afv","LSan"),record,"LSan",1000);
sendMsg(context.getRootInActiveWindow(),context,record);
AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(node,"com.tencent.mm:id/afv","华"),record,"华",1000);
sendMsg(node,context,record);
AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(node,"com.tencent.mm:id/afv","Aoo"),record,"Aoo",1000);
sendMsg(node,context,record);
AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(node,"com.tencent.mm:id/afv","曼婷"),record,"Aoo",1000);
sendMsg(node,context,record);
AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(node,"com.tencent.mm:id/afv","苏苏"),record,"Aoo",1000);
sendMsg(node,context,record);
AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(node,"com.tencent.mm:id/afv","zh琪"),record,"Aoo",1000);
sendMsg(node,context,record);
}
}
示例8: dispatchOnDrawerOpened
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
void dispatchOnDrawerOpened(View drawerView) {
final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
if (!lp.knownOpen) {
lp.knownOpen = true;
if (mListener != null) {
mListener.onDrawerOpened(drawerView);
}
updateChildrenImportantForAccessibility(drawerView, true);
// Only send WINDOW_STATE_CHANGE if the host has window focus.
if (hasWindowFocus()) {
sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
drawerView.requestFocus();
}
}
示例9: performAccessibilityAction
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
@TargetApi(16)
@Override
public boolean performAccessibilityAction(int action, Bundle args) {
if (super.performAccessibilityAction(action, args)) {
return true;
}
if (duration <= 0) {
return false;
}
if (action == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) {
if (scrubIncrementally(-getPositionIncrement())) {
stopScrubbing(false);
}
} else if (action == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) {
if (scrubIncrementally(getPositionIncrement())) {
stopScrubbing(false);
}
} else {
return false;
}
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
return true;
}
示例10: onInitializeAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(host, event);
event.setClassName(DirectionalViewpager.class.getName());
AccessibilityRecordCompat recordCompat = null;
if (isHorizontal()) {
recordCompat =
AccessibilityEventCompat.asRecord(event);
} else {
recordCompat = AccessibilityRecordCompat.obtain();
}
recordCompat.setScrollable(canScroll());
if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
&& mAdapter != null) {
recordCompat.setItemCount(mAdapter.getCount());
recordCompat.setFromIndex(mCurItem);
recordCompat.setToIndex(mCurItem);
}
}
示例11: dispatchPopulateAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
event.setClassName(getClass().getName());
event.setPackageName(getPackageName());
LayoutParams params = getWindow().getAttributes();
boolean isFullScreen = (params.width == LayoutParams.MATCH_PARENT) &&
(params.height == LayoutParams.MATCH_PARENT);
event.setFullScreen(isFullScreen);
CharSequence title = getTitle();
if (!TextUtils.isEmpty(title)) {
event.getText().add(title);
}
return true;
}
示例12: dispatchPopulateAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
// Dispatch scroll events from this ViewPager.
if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
return super.dispatchPopulateAccessibilityEvent(event);
}
// Dispatch all other accessibility events from the current page.
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == VISIBLE) {
final ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == mCurItem &&
child.dispatchPopulateAccessibilityEvent(event)) {
return true;
}
}
}
return false;
}
示例13: sendScrollAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
private void sendScrollAccessibilityEvent() {
AccessibilityManager am =
(AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (am.isEnabled()) {
if (mCurrentPage != getNextPage()) {
AccessibilityEvent ev =
AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED);
ev.setScrollable(true);
ev.setScrollX(getScrollX());
ev.setScrollY(getScrollY());
ev.setMaxScrollX(mMaxScrollX);
ev.setMaxScrollY(0);
sendAccessibilityEventUnchecked(ev);
}
}
}
示例14: dispatchPopulateAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
final boolean result = super.dispatchPopulateAccessibilityEvent(event);
final List<CharSequence> text = event.getText();
text.clear();
// Populate event with a fake title based on the current state.
if (mState == State.APPS) {
text.add(getString(R.string.all_apps_button_label));
} else if (mState == State.WIDGETS) {
text.add(getString(R.string.widget_button_text));
} else if (mWorkspace != null) {
text.add(mWorkspace.getCurrentPageDescription());
} else {
text.add(getString(R.string.all_apps_home_button_label));
}
return result;
}
示例15: onInitializeAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入依赖的package包/类
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
if (getChildCount() > 0) {
final AccessibilityRecordCompat record = AccessibilityEventCompat
.asRecord(event);
final View start = findFirstVisibleItemClosestToStart(false, true);
final View end = findFirstVisibleItemClosestToEnd(false, true);
if (start == null || end == null) {
return;
}
final int startPos = getPosition(start);
final int endPos = getPosition(end);
if (startPos < endPos) {
record.setFromIndex(startPos);
record.setToIndex(endPos);
} else {
record.setFromIndex(endPos);
record.setToIndex(startPos);
}
}
}