Example usage for android.support.v4.view.accessibility AccessibilityNodeInfoCompat hashCode

List of usage examples for android.support.v4.view.accessibility AccessibilityNodeInfoCompat hashCode

Introduction

In this page you can find the example usage for android.support.v4.view.accessibility AccessibilityNodeInfoCompat hashCode.

Prototype

@Override
    public int hashCode() 

Source Link

Usage

From source file:com.android.utils.TreeDebug.java

private static void logNodeTree(AccessibilityNodeInfoCompat node, String indent,
        HashSet<AccessibilityNodeInfoCompat> seen) {
    if (!seen.add(node)) {
        LogUtils.log(TreeDebug.class, Log.VERBOSE, "Cycle: %d", node.hashCode());
        return;//from   ww w.  ja va2  s .  c  o  m
    }

    // Include the hash code as a "poor man's" id, knowing that it
    // might not always be unique.
    LogUtils.log(TreeDebug.class, Log.VERBOSE, "%s(%d)%s", indent, node.hashCode(), nodeDebugDescription(node));

    indent += "  ";
    int childCount = node.getChildCount();
    for (int i = 0; i < childCount; ++i) {
        AccessibilityNodeInfoCompat child = node.getChild(i);
        if (child == null) {
            LogUtils.log(TreeDebug.class, Log.VERBOSE, "%sCouldn't get child %d", indent, i);
            continue;
        }

        logNodeTree(child, indent, seen);
    }
}

From source file:com.google.android.marvin.mytalkback.speechrules.RuleNonTextViews.java

@Override
public CharSequence format(Context context, AccessibilityNodeInfoCompat node, AccessibilityEvent event) {
    final CharSequence text = super.format(context, node, event);
    final boolean isClickable = AccessibilityNodeInfoUtils.isClickable(node);
    final boolean hasLabel = !TextUtils.isEmpty(text);

    if (hasLabel) {
        // We speak labeled images as buttons if acitonable, or simply speak
        // their text if non-actionable.
        if (isClickable) {
            return context.getString(R.string.template_button, text);
        } else {/*from  ww  w  . ja  v a 2s .  c  o  m*/
            return text;
        }
    } else {
        // We provide as much information about the control as possible in
        // the case it is unlabeled.
        final int nodeInt = (node.hashCode() % 100);
        if (isClickable) {
            return context.getString(R.string.template_unlabeled_button, nodeInt);
        } else {
            return context.getString(R.string.template_unlabeled_image_view, nodeInt);
        }
    }
}

From source file:com.android.screenspeak.speechrules.RuleNonTextViews.java

@Override
public CharSequence format(Context context, AccessibilityNodeInfoCompat node, AccessibilityEvent event) {
    final CharSequence text = super.format(context, node, event);
    final boolean isClickable = AccessibilityNodeInfoUtils.isClickable(node);
    final boolean hasLabel = !TextUtils.isEmpty(text);

    if (hasLabel) {
        // We speak labeled images as buttons if acitonable, or simply speak
        // their text if non-actionable.
        if (isClickable) {
            String resultText = context.getString(R.string.template_button, text);
            return StringBuilderUtils.createSpannableFromTextWithTemplate(resultText, text);
        } else {//from  ww  w . j a v a  2s .  c o m
            return text;
        }
    } else {
        if (mLabelManager != null) {
            // Check to see if a custom label exists for the unlabeled control.
            Label label = mLabelManager.getLabelForViewIdFromCache(node.getViewIdResourceName());
            if (label != null) {
                final CharSequence labelText = label.getText();
                if (isClickable) {
                    return context.getString(R.string.template_button, labelText);
                } else {
                    return labelText;
                }
            }
        }

        // We provide as much information about the control as possible in
        // the case it is unlabeled.
        final int nodeInt = Math.abs(node.hashCode() % 100);
        if (isClickable) {
            return context.getString(R.string.template_unlabeled_button, nodeInt);
        } else {
            return context.getString(R.string.template_unlabeled_image_view, nodeInt);
        }
    }
}

From source file:com.google.android.marvin.talkback.speechrules.RuleNonTextViews.java

@Override
public CharSequence format(Context context, AccessibilityNodeInfoCompat node, AccessibilityEvent event) {
    final CharSequence text = super.format(context, node, event);
    final boolean isClickable = AccessibilityNodeInfoUtils.isClickable(node);
    final boolean hasLabel = !TextUtils.isEmpty(text);

    if (hasLabel) {
        // We speak labeled images as buttons if acitonable, or simply speak
        // their text if non-actionable.
        if (isClickable) {
            return context.getString(R.string.template_button, text);
        } else {//from  www .j  a v a2 s.c om
            return text;
        }
    } else {
        if (mLabelManager != null) {
            // TODO(caseyburkhardt): Eliminate this dance when support library is fixed.
            final AccessibilityNodeInfo unwrappedNode = (AccessibilityNodeInfo) node.getInfo();

            // Check to see if a custom label exists for the unlabeled control.
            final Label label = mLabelManager.getLabelForViewIdFromCache(unwrappedNode.getViewIdResourceName());
            if (label != null) {
                final CharSequence labelText = label.getText();
                if (isClickable) {
                    return context.getString(R.string.template_button, labelText);
                } else {
                    return labelText;
                }
            }
        }

        // We provide as much information about the control as possible in
        // the case it is unlabeled.
        final int nodeInt = (node.hashCode() % 100);
        if (isClickable) {
            return context.getString(R.string.template_unlabeled_button, nodeInt);
        } else {
            return context.getString(R.string.template_unlabeled_image_view, nodeInt);
        }
    }
}