private void restoreImportantForAccessibilityHelper(View v) { Integer important = mPreviousValues.get(v); v.setImportantForAccessibility(important); mPreviousValues.remove(v); // Call method on children recursively if (v instanceof ViewGroup) { ViewGroup vg = (ViewGroup) v; // We assume if a class implements OnHierarchyChangeListener, it listens // to changes to any of its children (happens to be the case in Launcher) if (vg instanceof OnHierarchyChangeListener) { vg.setOnHierarchyChangeListener((OnHierarchyChangeListener) vg); } else { vg.setOnHierarchyChangeListener(null); } for (int i = 0; i < vg.getChildCount(); i++) { View child = vg.getChildAt(i); if (includeView(child)) { restoreImportantForAccessibilityHelper(child); } } } }
public static void setFor(ViewGroup group) { if (group == null) { return; } OnHierarchyChangeListener currentListener = getCurrentListener(group); if (currentListener instanceof PXHierarchyListener) { // We've already added ours to it, so nothing more to do. return; } // RadioGroup check to avoid StackOverflow issues. The RadioGroup uses a // similar delegation technique that trigger a StackOverflow, so we // should not pass the currentListener to it. if (!(group instanceof RadioGroup)) { group.setOnHierarchyChangeListener(new PXHierarchyListener(currentListener)); } else { group.setOnHierarchyChangeListener(new PXHierarchyListener(null)); } addGlobalLayoutListener(group); }
private void restoreImportantForAccessibilityHelper(View v) { v.setImportantForAccessibility(mPreviousValues.get(v)); mPreviousValues.remove(v); // Call method on children recursively if (v instanceof ViewGroup) { ViewGroup vg = (ViewGroup) v; // We assume if a class implements OnHierarchyChangeListener, it listens // to changes to any of its children (happens to be the case in Launcher) if (vg instanceof OnHierarchyChangeListener) { vg.setOnHierarchyChangeListener((OnHierarchyChangeListener) vg); } else { vg.setOnHierarchyChangeListener(null); } for (int i = 0; i < vg.getChildCount(); i++) { View child = vg.getChildAt(i); if (includeView(child)) { restoreImportantForAccessibilityHelper(child); } } } }
public static OnHierarchyChangeListener getCurrentListener(ViewGroup viewGroup) { if (sHierarchyListenerField == null) { initReflection(); } if (sHierarchyListenerField == null) { PXLog.w(TAG, "Unable to fetch the ViewGroup's current hierarchy listener. " + "Reflection failed."); return null; } Object listener; try { listener = sHierarchyListenerField.get(viewGroup); } catch (Exception e) { PXLog.e(TAG, "Unable to fetch the ViewGroup's current hierarchy listener. " + "Reflection failed."); return null; } if (listener == null || listener instanceof OnHierarchyChangeListener) { return (OnHierarchyChangeListener) listener; } else { PXLog.w(TAG, "A hierarchy listener was found, but its type is unexpected: %s", listener .getClass().getName()); return null; } }
/** * Just used for debug purposes. TODO delete. * * @param viewGroup */ public static void logCurrentListener(ViewGroup viewGroup) { OnHierarchyChangeListener currentListener = getCurrentListener(viewGroup); if (currentListener == null) { PXLog.d(TAG, "%s has no hierarchy listener.", viewGroup.getClass().getSimpleName()); } else { PXLog.d(TAG, "%s has hierarchy listener {1}", viewGroup.getClass().getSimpleName(), currentListener.getClass().getSimpleName()); } }
/** * @see ViewGroup#setOnHierarchyChangeListener(OnHierarchyChangeListener) */ public W setOnHierarchyChangeListener(OnHierarchyChangeListener listener) { mView.setOnHierarchyChangeListener(listener); return (W) this; }
public void setOnHierarchyChangeListener(OnHierarchyChangeListener onHierarchyChangeListener) { this.mOnHierarchyChangeListener = onHierarchyChangeListener; }
public Disposable onHierarchyChange(final OnHierarchyChangeListener onNext) { return onHierarchyChange(onNext, Fu.ON_ERROR_MISSING); }
public Disposable onHierarchyChange(final OnHierarchyChangeListener onNext, final Consumer<? super Exception> onError) { return onHierarchyChange(onNext, onError, Fu.EMPTY_ACTION); }
public void setOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener paramOnHierarchyChangeListener) { this.mOnHierarchyChangeListener = paramOnHierarchyChangeListener; }
public PXHierarchyListener(OnHierarchyChangeListener existingListener) { mExistingListener = existingListener; }