Java Code Examples for android.view.ViewGroup#setOnHierarchyChangeListener()

The following examples show how to use android.view.ViewGroup#setOnHierarchyChangeListener() . 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: ReactNativeTabActivity.java    From native-navigation with MIT License 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_tab_2);
  bottomNavigationView = (ReactBottomNavigation) findViewById(R.id.bottom_navigation);
  bottomNavigationView.setOnNavigationItemSelectedListener(this);
  tabConfigContainer = (ViewGroup) findViewById(R.id.tab_config_container);
  tabConfigContainer.setOnHierarchyChangeListener(reactViewChangeListener);
  ScreenCoordinatorLayout container = (ScreenCoordinatorLayout) findViewById(R.id.content);
  tabCoordinator = new TabCoordinator(this, container, savedInstanceState);

  ReactNativeFragment tabConfigFragment = ReactNativeFragment.newInstance("TabScreen", null);
  getSupportFragmentManager().beginTransaction()
          .add(R.id.tab_config_container, tabConfigFragment)
          .commitNow();
}
 
Example 2
Source File: HideFromAccessibilityHelper.java    From TurboLauncher with Apache License 2.0 6 votes vote down vote up
private void setImportantForAccessibilityToNoHelper(View v) {
    mPreviousValues.put(v, v.getImportantForAccessibility());
    v.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);

    // Call method on children recursively
    if (v instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) v;
        vg.setOnHierarchyChangeListener(this);
        for (int i = 0; i < vg.getChildCount(); i++) {
            View child = vg.getChildAt(i);

            if (includeView(child)) {
                setImportantForAccessibilityToNoHelper(child);
            }
        }
    }
}
 
Example 3
Source File: HideFromAccessibilityHelper.java    From TurboLauncher with Apache License 2.0 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example 4
Source File: PXHierarchyListener.java    From pixate-freestyle-android with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 5
Source File: Coordinators.java    From coordinators with Apache License 2.0 5 votes vote down vote up
/**
 * Installs a binder that calls {@link #bind(View, CoordinatorProvider)} for any child view added
 * to the group.
 */
public static void installBinder(@NonNull ViewGroup viewGroup,
    @NonNull final CoordinatorProvider provider) {
  int childCount = viewGroup.getChildCount();
  for (int i = 0; i < childCount; i++) {
    bind(viewGroup.getChildAt(i), provider);
  }
  viewGroup.setOnHierarchyChangeListener(new Binder(provider));
}
 
Example 6
Source File: HierarchyTreeChangeListener.java    From debugdrawer with Apache License 2.0 5 votes vote down vote up
@Override public void onChildViewAdded(View parent, View child) {
  delegate.onChildViewAdded(parent, child);

  if (child instanceof ViewGroup) {
    ViewGroup childGroup = (ViewGroup) child;
    childGroup.setOnHierarchyChangeListener(this);
    for (int i = 0; i < childGroup.getChildCount(); i++) {
      onChildViewAdded(childGroup, childGroup.getChildAt(i));
    }
  }
}
 
Example 7
Source File: HierarchyTreeChangeListener.java    From debugdrawer with Apache License 2.0 5 votes vote down vote up
@Override public void onChildViewRemoved(View parent, View child) {
  if (child instanceof ViewGroup) {
    ViewGroup childGroup = (ViewGroup) child;
    for (int i = 0; i < childGroup.getChildCount(); i++) {
      onChildViewRemoved(childGroup, childGroup.getChildAt(i));
    }
    childGroup.setOnHierarchyChangeListener(null);
  }

  delegate.onChildViewRemoved(parent, child);
}
 
Example 8
Source File: HierarchyTreeChangeListener.java    From u2020-mvp with Apache License 2.0 5 votes vote down vote up
@Override
public void onChildViewAdded(View parent, View child) {
    delegate.onChildViewAdded(parent, child);

    if (child instanceof ViewGroup) {
        ViewGroup childGroup = (ViewGroup) child;
        childGroup.setOnHierarchyChangeListener(this);
        for (int i = 0; i < childGroup.getChildCount(); i++) {
            onChildViewAdded(childGroup, childGroup.getChildAt(i));
        }
    }
}
 
Example 9
Source File: HierarchyTreeChangeListener.java    From u2020-mvp with Apache License 2.0 5 votes vote down vote up
@Override
public void onChildViewRemoved(View parent, View child) {
    if (child instanceof ViewGroup) {
        ViewGroup childGroup = (ViewGroup) child;
        for (int i = 0; i < childGroup.getChildCount(); i++) {
            onChildViewRemoved(childGroup, childGroup.getChildAt(i));
        }
        childGroup.setOnHierarchyChangeListener(null);
    }

    delegate.onChildViewRemoved(parent, child);
}
 
Example 10
Source File: HierarchyTreeChangeListener.java    From u2020 with Apache License 2.0 5 votes vote down vote up
@Override public void onChildViewAdded(View parent, View child) {
  delegate.onChildViewAdded(parent, child);

  if (child instanceof ViewGroup) {
    ViewGroup childGroup = (ViewGroup) child;
    childGroup.setOnHierarchyChangeListener(this);
    for (int i = 0; i < childGroup.getChildCount(); i++) {
      onChildViewAdded(childGroup, childGroup.getChildAt(i));
    }
  }
}
 
Example 11
Source File: HierarchyTreeChangeListener.java    From u2020 with Apache License 2.0 5 votes vote down vote up
@Override public void onChildViewRemoved(View parent, View child) {
  if (child instanceof ViewGroup) {
    ViewGroup childGroup = (ViewGroup) child;
    for (int i = 0; i < childGroup.getChildCount(); i++) {
      onChildViewRemoved(childGroup, childGroup.getChildAt(i));
    }
    childGroup.setOnHierarchyChangeListener(null);
  }

  delegate.onChildViewRemoved(parent, child);
}