List of usage examples for android.view ViewGroup getChildCount
public int getChildCount()
From source file:com.orange.ocara.ui.activity.ResultAuditActivity.java
private void updateAnomalies(Audit audit) { ViewGroup anomalyContainerView = (ViewGroup) findViewById(com.orange.ocara.R.id.anomaly_container); anomalyContainerView.removeAllViews(); for (AuditObject auditObject : audit.getObjects()) { final List<Comment> comments = auditObject.getComments(); final String auditObjectName = auditObject.getName(); final Uri auditObjectIcon = Uri.parse(auditObject.getObjectDescription().getIcon().toString()); if (auditObject.getResponse().equals(Response.NOK) || !auditObject.getComments().isEmpty()) { final AuditObjectAnomalyView auditObjectAnomalyView = AuditObjectAnomalyView_ .build(getApplicationContext()); auditObjectAnomalyView.setOnGroupClickListener(new AuditObjectAnomalyView.OnGroupClickListener() { @Override//from ww w . j a va2 s. c o m public void onExpand(AuditObjectAnomalyView view) { scrollTo(view); } }); auditObjectAnomalyView .setOnCommentClickListener(new AuditObjectAnomalyView.OnCommentClickListener() { @Override public void onCommentClick(Comment comment, View CommentView) { ResultAuditActivity.this.onCommentClicked(auditObjectIcon, auditObjectName, comments, comment, CommentView); } }); auditObjectAnomalyView.bind(auditObject); anomalyContainerView.addView(auditObjectAnomalyView); } } anomalyLayout.setVisibility(anomalyContainerView.getChildCount() > 0 ? View.VISIBLE : View.GONE); }
From source file:com.android.leanlauncher.Workspace.java
/** * Removes items that match the item info specified. When applications are removed * as a part of an update, this is called to ensure that other widgets and application * shortcuts are not removed.// ww w . ja v a 2 s . c o m */ void removeItemsByComponentName(final HashSet<ComponentName> componentNames, final UserHandleCompat user) { final ViewGroup layout = mWorkspace.getShortcutsAndWidgets(); final ArrayMap<ItemInfo, View> children = new ArrayMap<>(); for (int j = 0; j < layout.getChildCount(); j++) { final View view = layout.getChildAt(j); children.put((ItemInfo) view.getTag(), view); } final ArrayList<View> childrenToRemove = new ArrayList<View>(); LauncherModel.ItemInfoFilter filter = new LauncherModel.ItemInfoFilter() { @Override public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) { if (componentNames.contains(cn) && info.user.equals(user)) { childrenToRemove.add(children.get(info)); return true; } return false; } }; LauncherModel.filterItemInfos(children.keySet(), filter); // Remove all the other children for (View child : childrenToRemove) { // Note: We can not remove the view directly from CellLayoutChildren as this // does not re-mark the spaces as unoccupied. mWorkspace.removeViewInLayout(child); if (child instanceof DropTarget) { mDragController.removeDropTarget((DropTarget) child); } } if (childrenToRemove.size() > 0) { layout.requestLayout(); layout.invalidate(); } }
From source file:org.bangbang.support.v4.widget.ViewPager.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dx Delta scrolled in pixels/*from w ww .j a v a2s . co m*/ * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && android.support.v4.view.ViewCompat.canScrollHorizontally(v, -dx); }
From source file:org.alfresco.mobile.android.application.ui.form.FormManager.java
private void createPropertyFields(FieldGroupConfig group, ViewGroup hookView, LayoutInflater li, boolean isEdition) { ViewGroup groupview = hookView; ViewGroup grouprootview = null;/*from w w w. jav a 2 s. c o m*/ // Header if (!TextUtils.isEmpty(group.getLabel())) { grouprootview = (ViewGroup) li.inflate(R.layout.form_header, null); TextView tv = (TextView) grouprootview.findViewById(R.id.title); tv.setText(group.getLabel()); groupview = (ViewGroup) grouprootview.findViewById(R.id.group_panel); hookView.addView(grouprootview); } // For each properties, display the line associated for (FieldConfig fieldConfig : group.getItems()) { if (fieldConfig instanceof FieldGroupConfig) { createPropertyFields((FieldGroupConfig) fieldConfig, groupview, li, isEdition); continue; } // Retrieve the Field builder based on config Property nodeProp = node.getProperty(fieldConfig.getModelIdentifier()); View fieldView = null; BaseField field = generateField(nodeProp, fieldConfig, groupview, isEdition); if (field == null) { continue; } fieldsOrderIndex.add(field); fieldsIndex.put(fieldConfig.getModelIdentifier(), field); // Mark All fields in edition mode if (isEdition) { // Mark required Field if (field.isRequired()) { mandatoryFields.add(field); } } // If requires fragment for pickers. if (field.isPickerRequired()) { field.setFragment(fr); } if (field.requireExtra()) { Bundle b = new Bundle(); b.putSerializable(PathField.EXTRA_PARENT_FOLDER, parentFolder); field.setExtra(b); } // If requires Async if (field.requireAsync() && !modelRequested.contains(fieldConfig.getModelIdentifier())) { String requestId = Operator.with(getActivity()).load(field.requestData(node)); RequestHolder holder = new RequestHolder(field, fieldConfig.getModelIdentifier(), requestId); modelRequested.add(fieldConfig.getModelIdentifier()); operationFieldIndex.put(requestId, holder); } } if (groupview.getChildCount() == 0 && grouprootview != null) { grouprootview.setVisibility(View.GONE); } }
From source file:org.bangbang.support.v4.widget.VerticalViewPager.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dy Delta scrolled in pixels/*from w w w.j a v a2 s . c om*/ * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && android.support.v4.view.ViewCompat.canScrollVertically(v, -dy); }
From source file:com.gome.ecmall.custom.VerticalViewPager.java
/** * Tests scrollability within child views of v given a delta of dx. * //from ww w.j ava 2s. co m * @param v * View to test for horizontal scrollability * @param checkV * Whether the view v passed should itself be checked for scrollability (true), or just its children * (false). * @param dx * Delta scrolled in pixels * @param x * X coordinate of the active touch point * @param y * Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance // first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollVertically(v, -dy); }
From source file:com.brantapps.viewpagerindicator.vertical.VerticalViewPager.java
/** * Tests scrollability within child views of v given a delta of dy. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dy Delta scrolled in pixels// w ww . j a v a 2 s.co m * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dy. */ // BrantApps Change: Renamed dx to dy protected boolean canScroll(View v, boolean checkV, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } // BrantApps Change: Replaced canScrollHorizontally with canScrollVertically return checkV && ViewCompat.canScrollVertically(v, -dy); }
From source file:com.jackie.sample.custom_view.CustomViewPagerInternal.java
/** * Tests scrollability within child views of v given a delta of dx. * //ww w .ja v a2 s . co m * @param v * View to test for horizontal scrollability * @param checkV * Whether the view v passed should itself be checked for scrollability (true), or just its children (false). * @param dx * Delta scrolled in pixels * @param x * X coordinate of the active touch point * @param y * Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { if (!canScroll) { return true; } if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollHorizontally(v, -dx); }
From source file:org.de.jmg.learn.MainActivity.java
private void _SetShowAsAction(final MenuItem m) { final View tb = this.findViewById(R.id.action_bar); int SizeOther = 0; int width;//from ww w. j a v a 2 s . c o m ActionMenu = null; if (tb != null) { width = tb.getWidth(); Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); double height = metrics.heightPixels; int viewTop = this.findViewById(Window.ID_ANDROID_CONTENT).getTop(); double scale = (height - viewTop) / (double) 950; if (scale < .5f) { isSmallDevice = true; } double ActionBarHeight = tb.getHeight(); if (isSmallDevice && ActionBarHeight / height > .15f) { try { FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) tb.getLayoutParams(); layoutParams.height = (int) (height * .15f); tb.setMinimumHeight((int) (height * .15f)); tb.setLayoutParams(layoutParams); tb.requestLayout(); } catch (Exception ex) { Log.e("SetToolbarHeight", ex.getMessage(), ex); } } if (width > 0) { ViewGroup g = (ViewGroup) tb; for (int i = 0; i < g.getChildCount(); i++) { View v = g.getChildAt(i); if ((v instanceof android.support.v7.widget.ActionMenuView)) { SizeOther += v.getWidth(); ActionMenu = (android.support.v7.widget.ActionMenuView) v; } } if (SizeOther < width * .7) _blnReverse = true; if ((_blnReverse || SizeOther > width * .7) && ActionMenu != null) { if (_blnReverse) { //if (!_hasBeenDownsized || _hasBeenDownsized) //{ MenuBuilder mm = (MenuBuilder) ActionMenu.getMenu(); int Actions = mm.getActionItems().size(); try { MenuItem mmm = ActionMenu.getMenu().getItem(Actions + _invisibleCount); if (mmm.isVisible()) { MenuItemCompat.setShowAsAction(mmm, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); } else { _invisibleCount += 1; _SetShowAsAction(mmm); } } catch (IndexOutOfBoundsException ex) { return; } //} } else { MenuItemCompat.setShowAsAction(m, MenuItemCompat.SHOW_AS_ACTION_NEVER); _hasBeenDownsized = true; } ActionMenu.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (ActionMenu != null) { lib.removeLayoutListener(ActionMenu.getViewTreeObserver(), this); int SizeNew = ActionMenu.getWidth(); Log.v("Test", "" + SizeNew); MenuBuilder mm = (MenuBuilder) ActionMenu.getMenu(); int count = mm.getActionItems().size(); if (count >= 1 && !(_blnReverse && SizeNew > tb.getWidth() * .7)) { MenuItem m = mm.getActionItems().get(count - 1); _SetShowAsAction(m); } } } }); } } } }
From source file:com.jstudio.widget.pager.VerticalViewPager.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dy Delta scrolled in pixels/* w w w . ja va2 s.c o m*/ * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollVertically(v, -dy); }