Java Code Examples for android.view.View#AccessibilityDelegate

The following examples show how to use android.view.View#AccessibilityDelegate . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseViewVisitor.java    From ans-android-sdk with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void cleanup() {
    for (final Map.Entry<View, TrackingAccessibilityDelegate> entry :
            mWatching.entrySet()) {
        final View v = entry.getKey();
        final TrackingAccessibilityDelegate toCleanup = entry.getValue();
        final View.AccessibilityDelegate currentViewDelegate = getOldDelegate(v);
        if (currentViewDelegate == toCleanup) {
            v.setAccessibilityDelegate(toCleanup.getRealDelegate());
        } else if (currentViewDelegate instanceof TrackingAccessibilityDelegate) {
            final TrackingAccessibilityDelegate newChain =
                    (TrackingAccessibilityDelegate) currentViewDelegate;
            newChain.removeFromDelegateChain(toCleanup);
        } else {
            // Assume we've been replaced, zeroed out, or for some other reason we're
            // already gone.
            // (This isn't too weird, for example, it's expected when views get recycled)
        }
    }
    mWatching.clear();
}
 
Example 2
Source File: BaseViewVisitor.java    From ans-android-sdk with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void accumulate(View found) {
    final View.AccessibilityDelegate realDelegate = getOldDelegate(found);
    if (realDelegate instanceof TrackingAccessibilityDelegate) {
        final TrackingAccessibilityDelegate currentTracker =
                (TrackingAccessibilityDelegate) realDelegate;
        if (currentTracker.willFireEvent(UIHelper.textPropertyFromView(found),
                getEventName())) {
            return; // Don't double track
        }
    }

    // We aren't already in the tracking call chain of the view
    final TrackingAccessibilityDelegate newDelegate =
            new TrackingAccessibilityDelegate(realDelegate);
    found.setAccessibilityDelegate(newDelegate);
    mWatching.put(found, newDelegate);
}
 
Example 3
Source File: ComponentHost.java    From litho with Apache License 2.0 5 votes vote down vote up
@Override
public void setAccessibilityDelegate(View.AccessibilityDelegate accessibilityDelegate) {
  super.setAccessibilityDelegate(accessibilityDelegate);

  // We cannot compare against mComponentAccessibilityDelegate directly, since it is not the
  // delegate that we receive here. Instead, we'll set this to true at the point that we set that
  // delegate explicitly.
  mIsComponentAccessibilityDelegateSet = false;
}
 
Example 4
Source File: BaseViewVisitor.java    From ans-android-sdk with GNU General Public License v3.0 4 votes vote down vote up
public TrackingAccessibilityDelegate(View.AccessibilityDelegate realDelegate) {
    mRealDelegate = realDelegate;
}
 
Example 5
Source File: BaseViewVisitor.java    From ans-android-sdk with GNU General Public License v3.0 4 votes vote down vote up
public View.AccessibilityDelegate getRealDelegate() {
    return mRealDelegate;
}
 
Example 6
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void accessibilityDelegate(View.AccessibilityDelegate arg) {
  return BaseDSL.attr("accessibilityDelegate", arg);
}
 
Example 7
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void accessibilityDelegate(View.AccessibilityDelegate arg) {
  return BaseDSL.attr("accessibilityDelegate", arg);
}