FileDocCategorySizeDatePackage
AbsActionBarView.javaAPI DocAndroid 5.1 API10292Thu Mar 12 22:22:10 GMT 2015com.android.internal.widget

AbsActionBarView

public abstract class AbsActionBarView extends android.view.ViewGroup

Fields Summary
private static final android.animation.TimeInterpolator
sAlphaInterpolator
private static final int
FADE_DURATION
protected final VisibilityAnimListener
mVisAnimListener
protected final android.content.Context
mPopupContext
Context against which to inflate popup menus.
protected android.widget.ActionMenuView
mMenuView
protected android.widget.ActionMenuPresenter
mActionMenuPresenter
protected android.view.ViewGroup
mSplitView
protected boolean
mSplitActionBar
protected boolean
mSplitWhenNarrow
protected int
mContentHeight
protected android.animation.Animator
mVisibilityAnim
Constructors Summary
public AbsActionBarView(android.content.Context context)


       
        this(context, null);
    
public AbsActionBarView(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, 0);
    
public AbsActionBarView(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)

        this(context, attrs, defStyleAttr, 0);
    
public AbsActionBarView(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)

        super(context, attrs, defStyleAttr, defStyleRes);

        final TypedValue tv = new TypedValue();
        if (context.getTheme().resolveAttribute(R.attr.actionBarPopupTheme, tv, true)
                && tv.resourceId != 0) {
            mPopupContext = new ContextThemeWrapper(context, tv.resourceId);
        } else {
            mPopupContext = context;
        }
    
Methods Summary
public voidanimateToVisibility(int visibility)

        if (mVisibilityAnim != null) {
            mVisibilityAnim.cancel();
        }
        if (visibility == VISIBLE) {
            if (getVisibility() != VISIBLE) {
                setAlpha(0);
                if (mSplitView != null && mMenuView != null) {
                    mMenuView.setAlpha(0);
                }
            }
            ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 1);
            anim.setDuration(FADE_DURATION);
            anim.setInterpolator(sAlphaInterpolator);
            if (mSplitView != null && mMenuView != null) {
                AnimatorSet set = new AnimatorSet();
                ObjectAnimator splitAnim = ObjectAnimator.ofFloat(mMenuView, "alpha", 1);
                splitAnim.setDuration(FADE_DURATION);
                set.addListener(mVisAnimListener.withFinalVisibility(visibility));
                set.play(anim).with(splitAnim);
                set.start();
            } else {
                anim.addListener(mVisAnimListener.withFinalVisibility(visibility));
                anim.start();
            }
        } else {
            ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 0);
            anim.setDuration(FADE_DURATION);
            anim.setInterpolator(sAlphaInterpolator);
            if (mSplitView != null && mMenuView != null) {
                AnimatorSet set = new AnimatorSet();
                ObjectAnimator splitAnim = ObjectAnimator.ofFloat(mMenuView, "alpha", 0);
                splitAnim.setDuration(FADE_DURATION);
                set.addListener(mVisAnimListener.withFinalVisibility(visibility));
                set.play(anim).with(splitAnim);
                set.start();
            } else {
                anim.addListener(mVisAnimListener.withFinalVisibility(visibility));
                anim.start();
            }
        }
    
public booleancanShowOverflowMenu()

        return isOverflowReserved() && getVisibility() == VISIBLE;
    
public voiddismissPopupMenus()

        if (mActionMenuPresenter != null) {
            mActionMenuPresenter.dismissPopupMenus();
        }
    
public intgetAnimatedVisibility()

return
Current visibility or if animating, the visibility being animated to.

        if (mVisibilityAnim != null) {
            return mVisAnimListener.mFinalVisibility;
        }
        return getVisibility();
    
public intgetContentHeight()

        return mContentHeight;
    
public booleanhideOverflowMenu()

        if (mActionMenuPresenter != null) {
            return mActionMenuPresenter.hideOverflowMenu();
        }
        return false;
    
public booleanisOverflowMenuShowPending()

        if (mActionMenuPresenter != null) {
            return mActionMenuPresenter.isOverflowMenuShowPending();
        }
        return false;
    
public booleanisOverflowMenuShowing()

        if (mActionMenuPresenter != null) {
            return mActionMenuPresenter.isOverflowMenuShowing();
        }
        return false;
    
public booleanisOverflowReserved()

        return mActionMenuPresenter != null && mActionMenuPresenter.isOverflowReserved();
    
protected intmeasureChildView(android.view.View child, int availableWidth, int childSpecHeight, int spacing)

        child.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST),
                childSpecHeight);

        availableWidth -= child.getMeasuredWidth();
        availableWidth -= spacing;

        return Math.max(0, availableWidth);
    
protected static intnext(int x, int val, boolean isRtl)

        return isRtl ? x - val : x + val;
    
protected voidonConfigurationChanged(android.content.res.Configuration newConfig)

        super.onConfigurationChanged(newConfig);

        // Action bar can change size on configuration changes.
        // Reread the desired height from the theme-specified style.
        TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.ActionBar,
                com.android.internal.R.attr.actionBarStyle, 0);
        setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
        a.recycle();
        if (mSplitWhenNarrow) {
            setSplitToolbar(getContext().getResources().getBoolean(
                    com.android.internal.R.bool.split_action_bar_is_narrow));
        }
        if (mActionMenuPresenter != null) {
            mActionMenuPresenter.onConfigurationChanged(newConfig);
        }
    
protected intpositionChild(android.view.View child, int x, int y, int contentHeight, boolean reverse)

        int childWidth = child.getMeasuredWidth();
        int childHeight = child.getMeasuredHeight();
        int childTop = y + (contentHeight - childHeight) / 2;

        if (reverse) {
            child.layout(x - childWidth, childTop, x, childTop + childHeight);
        } else {
            child.layout(x, childTop, x + childWidth, childTop + childHeight);
        }

        return  (reverse ? -childWidth : childWidth);
    
public voidpostShowOverflowMenu()

        post(new Runnable() {
            public void run() {
                showOverflowMenu();
            }
        });
    
public voidsetContentHeight(int height)

        mContentHeight = height;
        requestLayout();
    
public voidsetSplitToolbar(boolean split)
Sets whether the bar should be split right now, no questions asked.

param
split true if the bar should split

        mSplitActionBar = split;
    
public voidsetSplitView(android.view.ViewGroup splitView)

        mSplitView = splitView;
    
public voidsetSplitWhenNarrow(boolean splitWhenNarrow)
Sets whether the bar should split if we enter a narrow screen configuration.

param
splitWhenNarrow true if the bar should check to split after a config change

        mSplitWhenNarrow = splitWhenNarrow;
    
public voidsetVisibility(int visibility)

        if (visibility != getVisibility()) {
            if (mVisibilityAnim != null) {
                mVisibilityAnim.end();
            }
            super.setVisibility(visibility);
        }
    
public booleanshowOverflowMenu()

        if (mActionMenuPresenter != null) {
            return mActionMenuPresenter.showOverflowMenu();
        }
        return false;