本文整理汇总了Java中android.view.accessibility.AccessibilityNodeInfo.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java AccessibilityNodeInfo.getChildCount方法的具体用法?Java AccessibilityNodeInfo.getChildCount怎么用?Java AccessibilityNodeInfo.getChildCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.accessibility.AccessibilityNodeInfo
的用法示例。
在下文中一共展示了AccessibilityNodeInfo.getChildCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildChildren
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private List<UiAutomationElement> buildChildren(AccessibilityNodeInfo node) {
List<UiAutomationElement> children;
int childCount = node.getChildCount();
if (childCount == 0) {
children = null;
} else {
children = new ArrayList<UiAutomationElement>(childCount);
for (int i = 0; i < childCount; i++) {
AccessibilityNodeInfo child = node.getChild(i);
if (child != null && child.isVisibleToUser()) {
children.add(this.getElement(child, this, i));
}
}
}
return children;
}
示例2: getOpenButton
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private AccessibilityNodeInfo getOpenButton(AccessibilityNodeInfo node) {
if (null == node) return null;
if (node.getChildCount() == 0) {
if ("android.widget.Button".equals(node.getClassName()))
return node;
else
return null;
}
AccessibilityNodeInfo button;
for (int i = 0; i < node.getChildCount(); i++) {
button = getOpenButton(node.getChild(i));
if (button != null)
return button;
}
return null;
}
示例3: iteratorSMZDM
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void iteratorSMZDM(AccessibilityNodeInfo info) {
if (info.getChildCount() == 0 && info.getText() != null) {
if (info.getText().equals("签到")) {
AccessibilityNodeInfo parent = info.getParent();
if ("android.widget.RelativeLayout".equals(parent.getClassName())
&& parent.isClickable()) {
parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
found = true;
return;
}
}
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if(info.getChild(i)!=null){
if (found) {
found = false;
break;
}
iteratorSMZDM(info.getChild(i));
}
}
}
return ;
}
示例4: iterator
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void iterator(AccessibilityNodeInfo info, AccessibilityService service) {
if (info.getText() != null) {
if (info.getText().equals("签到") && info.isClickable()) {
info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
delay(3000);
iterator(service.getRootInActiveWindow(), service);
found = true;
return;
}
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if(info.getChild(i)!=null){
if (found) {
found = false;
break;
}
iterator(info.getChild(i), service);
}
}
}
return ;
}
示例5: findChildViews
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/**
* Traverses the node structure and finds edit texts, adding them to the edit text node list
* @param parentView
*/
private void findChildViews(AccessibilityNodeInfo parentView) {
if (parentView != null) {
// Get number of children of a node
int childCount = parentView.getChildCount();
if (parentView.getClassName() == null) {
return;
}
// Get node class name
String classname = parentView.getClassName().toString();
if (childCount == 0 && (classname.contentEquals("android.widget.EditText"))) {
// If the node is an end node and it is an edit text, add it to the list
editTextNodes.add(parentView);
} else {
// Otherwise loop through any child nodes and try on them
for (int i = 0; i < childCount; i++) {
findChildViews(parentView.getChild(i));
}
}
}
}
示例6: serialize
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public static SerializedAccessibilityNodeInfo serialize(AccessibilityNodeInfo node){
SerializedAccessibilityNodeInfo serializedNode = new SerializedAccessibilityNodeInfo();
Rect boundsInScreen = new Rect(), boundsInParent = new Rect();
if(node == null){
return null;
}
if(node.getClassName() != null)
serializedNode.className = node.getClassName().toString();
node.getBoundsInScreen(boundsInScreen);
node.getBoundsInParent(boundsInParent);
serializedNode.boundsInScreen = boundsInScreen.flattenToString();
serializedNode.boundsInParent = boundsInParent.flattenToString();
if(node.getContentDescription() != null)
serializedNode.contentDescription = node.getContentDescription().toString();
if(node.getText() != null){
serializedNode.text = node.getText().toString();
}
if(node.getViewIdResourceName() != null)
serializedNode.viewId = node.getViewIdResourceName();
int childCount = node.getChildCount();
for(int i = 0; i < childCount; i ++){
if(node.getChild(i) != null){
serializedNode.children.add(serialize(node.getChild(i)));
}
}
return serializedNode;
}
示例7: findChildView
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void findChildView(AccessibilityNodeInfo info, String findText) {
String text = info.getText() + "";
boolean isContentTxl = text.equals(findText);
if (info.getChildCount() == 0) {
if (!TextUtils.isEmpty(text) && isContentTxl) {
L.e("Text:" + text + "是否" + isContentTxl + "是否2" + text.equals("通讯录"));
performClick(info);
}
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if (info.getChild(i) != null) {
findChildView(info.getChild(i), findText);
}
}
}
}
示例8: findNodeInfosByName
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public static void findNodeInfosByName(AccessibilityNodeInfo nodeInfo, String name) {
if (TextUtils.isEmpty(name)) {
L.e("name is null" + name);
return;
}
if (nodeInfo == null) {
L.e("nodeInfo is null " + nodeInfo);
return;
}
// L.d("findNodeInfosByName "+nodeInfo.getText());
if (name.equals(nodeInfo.getClassName())) {
editText = nodeInfo;
return;
}
for (int i = 0; i < nodeInfo.getChildCount(); i++) {
findNodeInfosByName(nodeInfo.getChild(i), name);
}
}
示例9: findNodeInfosById
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public static List<AccessibilityNodeInfo> findNodeInfosById(AccessibilityNodeInfo nodeInfo, String id) {
if (TextUtils.isEmpty(id)) {
L.e("name is null" + id);
return nodeInfoList;
}
if (nodeInfo == null) {
L.e("nodeInfo is null " + nodeInfo);
return nodeInfoList;
}
// L.d("findNodeInfosByName "+nodeInfo.getText());
String viewIdResourceName = nodeInfo.getViewIdResourceName();
L.d("viewIdResourceName " + viewIdResourceName + " child Count " + nodeInfo.getChildCount());
if (id.equals(viewIdResourceName)) {
nodeInfoList.add(nodeInfo);
return nodeInfoList;
}
for (int i = 0; i < nodeInfo.getChildCount(); i++) {
findNodeInfosByName(nodeInfo.getChild(i), id);
}
return nodeInfoList;
}
示例10: clickLastMsg
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/** 点最新消息 */
private boolean clickLastMsg(AccessibilityNodeInfo nodeInfo) {
boolean isClick = false;
AccessibilityNodeInfo listView = AccessibilityUtils.findNodeInfosById(nodeInfo, ID_LIST_CHAT);
if(listView == null){
return isClick;
}
int childCount = listView.getChildCount();
if(childCount <= 0){
return isClick;
}
AccessibilityNodeInfo item = listView.getChild(childCount - 1);
if(item != null){ // 每一条新消息都试着点红包
AccessibilityNodeInfo real = AccessibilityUtils.findNodeInfosById(item, ID_LIST_CHAT_ITEM_VIEW);
if(real != null) { // 真红包
// 新版本后, 1100(包括)以上, 能判断红包是否已经领取
if(mService.getWeChatPackageInfo().versionCode >= WeChatConfig.V_1100){
AccessibilityNodeInfo realToo = AccessibilityUtils.findNodeInfosByTexts(real, KEY_SEARCH, KEY_SEARCH_SELF);
if(realToo == null){
return isClick;
}
}
if(clickRedPacket(nodeInfo, real)){
isReceived = isClick = true;
}
}else{
isClick = false;
LogUtils.printOut("------非红包------");
}
}
return isClick;
}
示例11: refreshChildList
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
private void refreshChildList(AccessibilityNodeInfo root) {
if (root == null)
return;
root.refresh();
int childCount = root.getChildCount();
for (int i = 0; i < childCount; i++) {
refreshChildList(root.getChild(i));
}
}
示例12: findAccessibilityNodeInfo
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/***
* Find a matched node by tracing the tree of nodes.
* @param source
* @param text
* @return
*/
public static AccessibilityNodeInfo findAccessibilityNodeInfo(AccessibilityNodeInfo source, String text) {
AccessibilityNodeInfo accessibilityNodeInfo = null;
if (TextUtils.isEmpty(text)) {
return accessibilityNodeInfo;
}
for (int i = 0; i < source.getChildCount(); i++) {
AccessibilityNodeInfo compareNode = source.getChild(i);
if (compareNode != null && compareNode.getText() != null) {
LogUtils.LOGD(TAG, "(findAccessibilityNodeInfo) completeNode : " + compareNode.getClassName() + ", " + compareNode.getText());
if (text.equals(compareNode.getText())) {
LogUtils.LOGD(TAG, "(findAccessibilityNodeInfo) Find node : " + compareNode.getClassName() + ", " + compareNode.getText());
accessibilityNodeInfo = compareNode;
}
if (accessibilityNodeInfo == null) {
accessibilityNodeInfo = findAccessibilityNodeInfo(compareNode, text);
}
if (accessibilityNodeInfo == null) {
compareNode.recycle();
} else {
break;
}
}
}
return accessibilityNodeInfo;
}
示例13: preOrderTraverse
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/**
* traverse a tree from the root, and return all the notes in the tree
* @param root the root node
* @return a list of AccessibilityNodeInfo
*/
public static List<AccessibilityNodeInfo> preOrderTraverse(AccessibilityNodeInfo root){
if(root == null)
return null;
List<AccessibilityNodeInfo> list = new ArrayList<>();
list.add(root);
int childCount = root.getChildCount();
for(int i = 0; i < childCount; i ++){
AccessibilityNodeInfo node = root.getChild(i);
if(node != null)
list.addAll(preOrderTraverse(node));
}
return list;
}
示例14: recycle
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public void recycle(AccessibilityNodeInfo info) {
try {
if (info.getChildCount() == 0) {
if (info.getText() != null) {
if ("领取红包".equals(info.getText().toString())) {
if (info.isClickable()) {
info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
AccessibilityNodeInfo parent = info.getParent();
while (parent != null) {
if (parent.isClickable()) {
parents.add(parent);
break;
}
parent = parent.getParent();
}
}
}
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if (info.getChild(i) != null) {
recycle(info.getChild(i));
}
}
}
} catch (Exception e) {
}
}
示例15: parseNodeInfoAndOpenGetPacketDialog
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void parseNodeInfoAndOpenGetPacketDialog(AccessibilityNodeInfo accessibilityNodeInfo){
if(accessibilityNodeInfo != null && accessibilityNodeInfo.getChildCount() >0){
for(int i = 0;i<accessibilityNodeInfo.getChildCount();i++){
AccessibilityNodeInfo child = accessibilityNodeInfo.getChild(i);
parseNodeInfoAndOpenGetPacketDialog(child);
}
}else{
if(accessibilityNodeInfo != null && !TextUtils.isEmpty(accessibilityNodeInfo.getText())&&accessibilityNodeInfo.getText().toString().contains("领取红包")){
Log.i(TAG,"领取红包");
if(accessibilityNodeInfo.isClickable()){
accessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}else{
AccessibilityNodeInfo parent = accessibilityNodeInfo.getParent();
while(parent != null ){
if(parent.isClickable()){
parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
break;
}
parent = parent.getParent();
Log.i(TAG," 找到一个可以点击的节点");
}
}
}
}
}