Example usage for android.view.accessibility AccessibilityNodeInfo performAction

List of usage examples for android.view.accessibility AccessibilityNodeInfo performAction

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityNodeInfo performAction.

Prototype

public boolean performAction(int action) 

Source Link

Document

Performs an action on the node.

Usage

From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java

/**
 *
 *///from   w  w w. j  a  v a2 s  .c  om
public void recycle(AccessibilityNodeInfo info, String target, boolean isClickSelft) {
    int temp = 0;
    if (info != null && info.getChildCount() == 0) {
        if (info.getContentDescription() != null && info.getContentDescription().toString().equals(target)
                && isClickSelft) {

            String content = info.getContentDescription().toString();
            info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
            if (content.equals(AFTER_WORK))
                handleIt(info);
            else if (content.equals(GO_TO_WORK))
                handleGoToWork(info);
            return;
        }
        if (info.getText() != null) {
            if (target.equals(info.getText().toString())) {
                if (isClickSelft) {
                    info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
                    return;
                }
                AccessibilityNodeInfo parent = info.getParent();
                while (parent != null) {
                    if (parent.isClickable()) {
                        parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
                        break;
                    }
                    parent = parent.getParent();
                }
            }

        }
    } else {

        for (int i = 0; info != null && i < info.getChildCount(); i++) {
            if (info.getChild(i) != null) {
                temp = i;
                recycle(info.getChild(i), target, isClickSelft);
            }
        }
    }
}