List of usage examples for android.view ViewGroup getChildCount
public int getChildCount()
From source file:com.hellofyc.base.util.ViewUtils.java
@TargetApi(11) public static void setActionBarTranslation(Context context, float y) { int actionBarHeight = getActionBarHeight(context); ViewGroup content = ((ViewGroup) ((Activity) context).findViewById(android.R.id.content).getParent()); int children = content.getChildCount(); for (int i = 0; i < children; i++) { View child = content.getChildAt(i); if (child.getId() != android.R.id.content) { if (y <= -actionBarHeight) { child.setVisibility(View.GONE); } else { child.setVisibility(View.VISIBLE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { child.setTranslationY(y); }// ww w .jav a 2 s.c o m } } } }
From source file:com.jaspersoft.android.jaspermobile.test.utils.espresso.JasperMatcher.java
public static Matcher<View> childForPositionOf(final int position, final Matcher<View> parentMatcher) { return new TypeSafeMatcher<View>() { @Override//from w ww. j a v a2 s.c o m public void describeTo(Description description) { description.appendText( "with child on position " + position + " of parent " + parentMatcher.toString()); } @Override public boolean matchesSafely(View view) { if (!(view.getParent() instanceof ViewGroup)) { return parentMatcher.matches(view.getParent()); } ViewGroup group = (ViewGroup) view.getParent(); if (parentMatcher.matches(view.getParent())) { int childCount = group.getChildCount(); if (position >= childCount) { throw new RuntimeException("Position '" + position + "' should be lower than child count '" + childCount + "'"); } return group.getChildAt(position).equals(view); } else { return false; } } }; }
From source file:com.facebook.stetho.inspector.elements.android.AccessibilityNodeInfoWrapper.java
@Nullable public static CharSequence getDescription(AccessibilityNodeInfoCompat node, View view) { CharSequence contentDescription = node.getContentDescription(); CharSequence nodeText = node.getText(); boolean hasNodeText = !TextUtils.isEmpty(nodeText); boolean isEditText = view instanceof EditText; // EditText's prioritize their own text content over a contentDescription if (!TextUtils.isEmpty(contentDescription) && (!isEditText || !hasNodeText)) { return contentDescription; }//from w ww . j av a 2s. c o m if (hasNodeText) { return nodeText; } // If there are child views and no contentDescription the text of all non-focusable children, // comma separated, becomes the description. if (view instanceof ViewGroup) { final StringBuilder concatChildDescription = new StringBuilder(); final String separator = ", "; ViewGroup viewGroup = (ViewGroup) view; for (int i = 0, count = viewGroup.getChildCount(); i < count; i++) { final View child = viewGroup.getChildAt(i); AccessibilityNodeInfoCompat childNodeInfo = AccessibilityNodeInfoCompat.obtain(); ViewCompat.onInitializeAccessibilityNodeInfo(child, childNodeInfo); CharSequence childNodeDescription = null; if (AccessibilityUtil.isSpeakingNode(childNodeInfo, child) && !AccessibilityUtil.isAccessibilityFocusable(childNodeInfo, child)) { childNodeDescription = getDescription(childNodeInfo, child); } if (!TextUtils.isEmpty(childNodeDescription)) { if (concatChildDescription.length() > 0) { concatChildDescription.append(separator); } concatChildDescription.append(childNodeDescription); } childNodeInfo.recycle(); } return concatChildDescription.length() > 0 ? concatChildDescription.toString() : null; } return null; }
From source file:org.mariotaku.twidere.view.CardMediaContainer.java
private static int getChildIndicesInLayout(ViewGroup viewGroup, int[] indices) { final int childCount = viewGroup.getChildCount(); int indicesCount = 0; for (int i = 0; i < childCount; i++) { if (viewGroup.getChildAt(i).getVisibility() != GONE) { indices[indicesCount++] = i; }/*from w w w . j a va 2s. c o m*/ } return indicesCount; }
From source file:android.support.v7.testutils.TestUtilsMatchers.java
/** * Returns a matcher that matches {@link View}s based on the given child type. * * @param childMatcher the type of the child to match on */// w w w.j a va2s . c o m public static Matcher<ViewGroup> hasChild(final Matcher<View> childMatcher) { return new TypeSafeMatcher<ViewGroup>() { @Override public void describeTo(Description description) { description.appendText("has child: "); childMatcher.describeTo(description); } @Override public boolean matchesSafely(ViewGroup view) { final int childCount = view.getChildCount(); for (int i = 0; i < childCount; i++) { if (childMatcher.matches(view.getChildAt(i))) { return true; } } return false; } }; }
From source file:io.selendroid.server.model.internal.AbstractNativeElementContext.java
/** visible for testing */ protected static List<AndroidElement> searchViews(AbstractNativeElementContext context, List<View> roots, Predicate predicate, boolean findJustOne) { List<AndroidElement> elements = new ArrayList<AndroidElement>(); if (roots == null || roots.isEmpty()) { return elements; }//from ww w . j a v a 2 s .com ArrayDeque<View> queue = new ArrayDeque<View>(); for (View root : roots) { queue.add(root); while (!queue.isEmpty()) { View view = queue.pop(); if (predicate.apply(view)) { elements.add(context.newAndroidElement(view)); if (findJustOne) { break; } } if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; int childrenCount = group.getChildCount(); for (int index = 0; index < childrenCount; index++) { queue.add(group.getChildAt(index)); } } } } return elements; }
From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.utils.CustomRecyclerViewUtils.java
private static View findChildViewUnderWithoutTranslation(@NonNull ViewGroup parent, float x, float y) { final int count = parent.getChildCount(); for (int i = count - 1; i >= 0; i--) { final View child = parent.getChildAt(i); if (x >= child.getLeft() && x <= child.getRight() && y >= child.getTop() && y <= child.getBottom()) { return child; }/*from w w w. j a v a 2 s . co m*/ } return null; }
From source file:Main.java
/** * Borrowed from android.support.design.widget.AppBarLayout *//*from w w w . java2s . co m*/ public static int getMinimumHeightForVisibleOverlappingContent(ViewGroup appBarLayout) { final int topInset = getTopInset(appBarLayout); final int minHeight = ViewCompat.getMinimumHeight(appBarLayout); if (minHeight != 0) { // If this layout has a min height, use it (doubled) return (minHeight * 2) + topInset; } // Otherwise, we'll use twice the min height of our last child final int childCount = appBarLayout.getChildCount(); return childCount >= 1 ? (ViewCompat.getMinimumHeight(appBarLayout.getChildAt(childCount - 1)) * 2) + topInset : 0; }
From source file:android.support.transition.ViewOverlayApi14.java
static ViewOverlayApi14 createFrom(View view) { ViewGroup contentView = getContentView(view); if (contentView != null) { final int numChildren = contentView.getChildCount(); for (int i = 0; i < numChildren; ++i) { View child = contentView.getChildAt(i); if (child instanceof OverlayViewGroup) { return ((OverlayViewGroup) child).mViewOverlay; }//w ww . j a v a 2 s . com } return new ViewGroupOverlayApi14(contentView.getContext(), contentView, view); } return null; }
From source file:io.github.prefanatic.cleantap.util.AnimUtils.java
public static void hideChildren(ViewGroup group) { FastOutLinearInInterpolator interpolator = new FastOutLinearInInterpolator(); for (int i = 0; i < group.getChildCount(); i++) { View view = group.getChildAt(i); view.animate().alpha(0f).translationY(view.getHeight() / 3).setStartDelay(0L).setDuration(100L) .setInterpolator(interpolator).start(); }/*from w w w .ja v a2 s. co m*/ }