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

The following examples show how to use android.view.ViewGroup#setOnHierarchyChangeListener() . These examples are extracted from open source projects. 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
@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
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
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
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 Project: coordinators   File: Coordinators.java    License: 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
@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
@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
@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
@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
@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
@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);
}