Search in sources :

Example 86 with ViewGroup

use of android.view.ViewGroup in project httpclient by pixmob.

the class ActionBarView method setMenu.

public void setMenu(Menu menu, MenuPresenter.Callback cb) {
    if (menu == mOptionsMenu)
        return;
    if (mOptionsMenu != null) {
        mOptionsMenu.removeMenuPresenter(mActionMenuPresenter);
        mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter);
    }
    MenuBuilder builder = (MenuBuilder) menu;
    mOptionsMenu = builder;
    if (mMenuView != null) {
        final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
        if (oldParent != null) {
            oldParent.removeView(mMenuView);
        }
    }
    if (mActionMenuPresenter == null) {
        mActionMenuPresenter = new ActionMenuPresenter(mContext);
        mActionMenuPresenter.setCallback(cb);
        mActionMenuPresenter.setId(R.id.abs__action_menu_presenter);
        mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
    }
    ActionMenuView menuView;
    final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    if (!mSplitActionBar) {
        mActionMenuPresenter.setExpandedActionViewsExclusive(getResources_getBoolean(getContext(), R.bool.abs__action_bar_expanded_action_views_exclusive));
        configPresenters(builder);
        menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        final ViewGroup oldParent = (ViewGroup) menuView.getParent();
        if (oldParent != null && oldParent != this) {
            oldParent.removeView(menuView);
        }
        addView(menuView, layoutParams);
    } else {
        mActionMenuPresenter.setExpandedActionViewsExclusive(false);
        // Allow full screen width in split mode.
        mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true);
        // No limit to the item count; use whatever will fit.
        mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
        // Span the whole width
        layoutParams.width = LayoutParams.MATCH_PARENT;
        configPresenters(builder);
        menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        if (mSplitView != null) {
            final ViewGroup oldParent = (ViewGroup) menuView.getParent();
            if (oldParent != null && oldParent != mSplitView) {
                oldParent.removeView(menuView);
            }
            menuView.setVisibility(getAnimatedVisibility());
            mSplitView.addView(menuView, layoutParams);
        } else {
            // We'll add this later if we missed it this time.
            menuView.setLayoutParams(layoutParams);
        }
    }
    mMenuView = menuView;
}
Also used : ViewGroup(android.view.ViewGroup) ActionMenuView(com.actionbarsherlock.internal.view.menu.ActionMenuView) SubMenuBuilder(com.actionbarsherlock.internal.view.menu.SubMenuBuilder) MenuBuilder(com.actionbarsherlock.internal.view.menu.MenuBuilder) ActionMenuPresenter(com.actionbarsherlock.internal.view.menu.ActionMenuPresenter)

Example 87 with ViewGroup

use of android.view.ViewGroup in project httpclient by pixmob.

the class ActionMenuPresenter method updateMenuView.

@Override
public void updateMenuView(boolean cleared) {
    super.updateMenuView(cleared);
    if (mMenu != null) {
        final ArrayList<MenuItemImpl> actionItems = mMenu.getActionItems();
        final int count = actionItems.size();
        for (int i = 0; i < count; i++) {
            final ActionProvider provider = actionItems.get(i).getActionProvider();
            if (provider != null) {
                provider.setSubUiVisibilityListener(this);
            }
        }
    }
    final ArrayList<MenuItemImpl> nonActionItems = mMenu != null ? mMenu.getNonActionItems() : null;
    boolean hasOverflow = false;
    if (mReserveOverflow && nonActionItems != null) {
        final int count = nonActionItems.size();
        if (count == 1) {
            hasOverflow = !nonActionItems.get(0).isActionViewExpanded();
        } else {
            hasOverflow = count > 0;
        }
    }
    if (hasOverflow) {
        if (mOverflowButton == null) {
            mOverflowButton = new OverflowMenuButton(mSystemContext);
        }
        ViewGroup parent = (ViewGroup) mOverflowButton.getParent();
        if (parent != mMenuView) {
            if (parent != null) {
                parent.removeView(mOverflowButton);
            }
            ActionMenuView menuView = (ActionMenuView) mMenuView;
            menuView.addView(mOverflowButton, menuView.generateOverflowButtonLayoutParams());
        }
    } else if (mOverflowButton != null && mOverflowButton.getParent() == mMenuView) {
        ((ViewGroup) mMenuView).removeView(mOverflowButton);
    }
    ((ActionMenuView) mMenuView).setOverflowReserved(mReserveOverflow);
}
Also used : ActionProvider(com.actionbarsherlock.view.ActionProvider) ViewGroup(android.view.ViewGroup)

Example 88 with ViewGroup

use of android.view.ViewGroup in project httpclient by pixmob.

the class ActionMenuPresenter method findViewForItem.

private View findViewForItem(MenuItem item) {
    final ViewGroup parent = (ViewGroup) mMenuView;
    if (parent == null)
        return null;
    final int count = parent.getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = parent.getChildAt(i);
        if (child instanceof MenuView.ItemView && ((MenuView.ItemView) child).getItemData() == item) {
            return child;
        }
    }
    return null;
}
Also used : ViewGroup(android.view.ViewGroup) ActionMenuChildView(com.actionbarsherlock.internal.view.menu.ActionMenuView.ActionMenuChildView) View(android.view.View)

Example 89 with ViewGroup

use of android.view.ViewGroup in project httpclient by pixmob.

the class IcsListPopupWindow method dismiss.

public void dismiss() {
    mPopup.dismiss();
    if (mPromptView != null) {
        final ViewParent parent = mPromptView.getParent();
        if (parent instanceof ViewGroup) {
            final ViewGroup group = (ViewGroup) parent;
            group.removeView(mPromptView);
        }
    }
    mPopup.setContentView(null);
    mDropDownList = null;
    mHandler.removeCallbacks(mResizePopupRunnable);
}
Also used : ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup)

Example 90 with ViewGroup

use of android.view.ViewGroup in project platform_frameworks_base by android.

the class AbstractLayoutTest method animate.

public void animate(View v) {
    long start = System.currentTimeMillis();
    int N = 1000;
    for (int i = 0; i < N; i++) {
        ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
        lp.topMargin = (lp.topMargin + 1) % 31;
        lp.leftMargin = (lp.leftMargin + 1) % 31;
        v.requestLayout();
        v.invalidate();
        ViewGroup p = (ViewGroup) v.getParent();
        p.layout(0, 0, 1000 + (i % 2), 500 + (i % 2));
    }
    Log.d(tag(), "Time: " + (float) (System.currentTimeMillis() - start) / N * 1000 + "mics");
}
Also used : ViewGroup(android.view.ViewGroup)

Aggregations

ViewGroup (android.view.ViewGroup)2327 View (android.view.View)1300 TextView (android.widget.TextView)452 ImageView (android.widget.ImageView)282 ArrayList (java.util.ArrayList)204 ViewParent (android.view.ViewParent)185 ListView (android.widget.ListView)159 LayoutInflater (android.view.LayoutInflater)127 FrameLayout (android.widget.FrameLayout)127 Paint (android.graphics.Paint)126 AdapterView (android.widget.AdapterView)118 LinearLayout (android.widget.LinearLayout)113 AbsListView (android.widget.AbsListView)106 RecyclerView (android.support.v7.widget.RecyclerView)100 Drawable (android.graphics.drawable.Drawable)95 Animator (android.animation.Animator)94 AnimatedView (carbon.animation.AnimatedView)88 ComponentView (carbon.component.ComponentView)88 RippleView (carbon.drawable.ripple.RippleView)88 ShadowView (carbon.shadow.ShadowView)88