Search in sources :

Example 16 with ViewGroup

use of android.view.ViewGroup in project cw-omnibus by commonsguy.

the class BaseMenuPresenter method updateMenuView.

/**
     * Reuses item views when it can
     */
public void updateMenuView(boolean cleared) {
    final ViewGroup parent = (ViewGroup) mMenuView;
    if (parent == null)
        return;
    int childIndex = 0;
    if (mMenu != null) {
        mMenu.flagActionItems();
        ArrayList<MenuItemImpl> visibleItems = mMenu.getVisibleItems();
        final int itemCount = visibleItems.size();
        for (int i = 0; i < itemCount; i++) {
            MenuItemImpl item = visibleItems.get(i);
            if (shouldIncludeItem(childIndex, item)) {
                final View convertView = parent.getChildAt(childIndex);
                final MenuItemImpl oldItem = convertView instanceof MenuView.ItemView ? ((MenuView.ItemView) convertView).getItemData() : null;
                final View itemView = getItemView(item, convertView, parent);
                if (item != oldItem) {
                    // Don't let old states linger with new data.
                    itemView.setPressed(false);
                    if (IS_HONEYCOMB)
                        itemView.jumpDrawablesToCurrentState();
                }
                if (itemView != convertView) {
                    addItemView(itemView, childIndex);
                }
                childIndex++;
            }
        }
    }
    // Remove leftover views.
    while (childIndex < parent.getChildCount()) {
        if (!filterLeftoverView(parent, childIndex)) {
            childIndex++;
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) View(android.view.View)

Example 17 with ViewGroup

use of android.view.ViewGroup in project SimplifyReader by chentao0707.

the class SwipeBackLayout method attachToActivity.

public void attachToActivity(Activity activity) {
    mActivity = activity;
    TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
    int background = a.getResourceId(0, 0);
    a.recycle();
    ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundResource(background);
    decor.removeView(decorChild);
    addView(decorChild);
    setContentView(decorChild);
    decor.addView(this);
}
Also used : ViewGroup(android.view.ViewGroup) TypedArray(android.content.res.TypedArray)

Example 18 with ViewGroup

use of android.view.ViewGroup in project SimplifyReader by chentao0707.

the class ViewDragHelper method canScroll.

/**
     * 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 along the X axis
     * @param dy     Delta scrolled in pixels along the Y axis
     * @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 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();
        // 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, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }
    return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy));
}
Also used : ViewGroup(android.view.ViewGroup) View(android.view.View)

Example 19 with ViewGroup

use of android.view.ViewGroup in project Launcher3 by chislon.

the class AppsCustomizeTabHost method setVisibilityOfSiblingsWithLowerZOrder.

private void setVisibilityOfSiblingsWithLowerZOrder(int visibility) {
    ViewGroup parent = (ViewGroup) getParent();
    if (parent == null)
        return;
    View overviewPanel = ((Launcher) getContext()).getOverviewPanel();
    final int count = parent.getChildCount();
    if (!isChildrenDrawingOrderEnabled()) {
        for (int i = 0; i < count; i++) {
            final View child = parent.getChildAt(i);
            if (child == this) {
                break;
            } else {
                if (child.getVisibility() == GONE || child == overviewPanel) {
                    continue;
                }
                child.setVisibility(visibility);
            }
        }
    } else {
        throw new RuntimeException("Failed; can't get z-order of views");
    }
}
Also used : ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) View(android.view.View)

Example 20 with ViewGroup

use of android.view.ViewGroup in project Launcher3 by chislon.

the class FocusHelper method handleTabKeyEvent.

/**
     * Handles key events in the tab widget.
     */
static boolean handleTabKeyEvent(AccessibleTabView v, int keyCode, KeyEvent e) {
    if (!LauncherAppState.getInstance().isScreenLarge())
        return false;
    final FocusOnlyTabWidget parent = (FocusOnlyTabWidget) v.getParent();
    final TabHost tabHost = findTabHostParent(parent);
    final ViewGroup contents = tabHost.getTabContentView();
    final int tabCount = parent.getTabCount();
    final int tabIndex = parent.getChildTabIndex(v);
    final int action = e.getAction();
    final boolean handleKeyEvent = (action != KeyEvent.ACTION_UP);
    boolean wasHandled = false;
    switch(keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (handleKeyEvent) {
                // Select the previous tab
                if (tabIndex > 0) {
                    parent.getChildTabViewAt(tabIndex - 1).requestFocus();
                }
            }
            wasHandled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (handleKeyEvent) {
                // Select the next tab, or if the last tab has a focus right id, select that
                if (tabIndex < (tabCount - 1)) {
                    parent.getChildTabViewAt(tabIndex + 1).requestFocus();
                } else {
                    if (v.getNextFocusRightId() != View.NO_ID) {
                        tabHost.findViewById(v.getNextFocusRightId()).requestFocus();
                    }
                }
            }
            wasHandled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            // Do nothing
            wasHandled = true;
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (handleKeyEvent) {
                // Select the content view
                contents.requestFocus();
            }
            wasHandled = true;
            break;
        default:
            break;
    }
    return wasHandled;
}
Also used : TabHost(android.widget.TabHost) ViewGroup(android.view.ViewGroup)

Aggregations

ViewGroup (android.view.ViewGroup)2280 View (android.view.View)1268 TextView (android.widget.TextView)439 ImageView (android.widget.ImageView)279 ArrayList (java.util.ArrayList)198 ViewParent (android.view.ViewParent)184 ListView (android.widget.ListView)156 Paint (android.graphics.Paint)125 FrameLayout (android.widget.FrameLayout)121 LayoutInflater (android.view.LayoutInflater)115 AdapterView (android.widget.AdapterView)115 LinearLayout (android.widget.LinearLayout)110 AbsListView (android.widget.AbsListView)106 Animator (android.animation.Animator)94 Drawable (android.graphics.drawable.Drawable)93 RecyclerView (android.support.v7.widget.RecyclerView)91 AnimatedView (carbon.animation.AnimatedView)88 ComponentView (carbon.component.ComponentView)88 RippleView (carbon.drawable.ripple.RippleView)88 ShadowView (carbon.shadow.ShadowView)88