FileDocCategorySizeDatePackage
AbsActionBarView.javaAPI DocAndroid 5.1 API9944Thu Mar 12 22:22:56 GMT 2015android.support.v7.internal.widget

AbsActionBarView

public abstract class AbsActionBarView extends android.view.ViewGroup

Fields Summary
private static final android.view.animation.Interpolator
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.support.v7.widget.ActionMenuView
mMenuView
protected android.support.v7.widget.ActionMenuPresenter
mActionMenuPresenter
protected android.view.ViewGroup
mSplitView
protected boolean
mSplitActionBar
protected boolean
mSplitWhenNarrow
protected int
mContentHeight
protected android.support.v4.view.ViewPropertyAnimatorCompat
mVisibilityAnim
Constructors Summary
AbsActionBarView(android.content.Context context)


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

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

        super(context, attrs, defStyle);

        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) {
                ViewCompat.setAlpha(this, 0f);
                if (mSplitView != null && mMenuView != null) {
                    ViewCompat.setAlpha(mMenuView, 0f);
                }
            }
            ViewPropertyAnimatorCompat anim = ViewCompat.animate(this).alpha(1f);
            anim.setDuration(FADE_DURATION);
            anim.setInterpolator(sAlphaInterpolator);
            if (mSplitView != null && mMenuView != null) {
                ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet();
                ViewPropertyAnimatorCompat splitAnim = ViewCompat.animate(mMenuView).alpha(1f);
                splitAnim.setDuration(FADE_DURATION);
                set.setListener(mVisAnimListener.withFinalVisibility(anim, visibility));
                set.play(anim).play(splitAnim);
                set.start();
            } else {
                anim.setListener(mVisAnimListener.withFinalVisibility(anim, visibility));
                anim.start();
            }
        } else {
            ViewPropertyAnimatorCompat anim = ViewCompat.animate(this).alpha(0f);
            anim.setDuration(FADE_DURATION);
            anim.setInterpolator(sAlphaInterpolator);
            if (mSplitView != null && mMenuView != null) {
                ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet();
                ViewPropertyAnimatorCompat splitAnim = ViewCompat.animate(mMenuView).alpha(0f);
                splitAnim.setDuration(FADE_DURATION);
                set.setListener(mVisAnimListener.withFinalVisibility(anim, visibility));
                set.play(anim).play(splitAnim);
                set.start();
            } else {
                anim.setListener(mVisAnimListener.withFinalVisibility(anim, 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)

        if (Build.VERSION.SDK_INT >= 8) {
            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,
                R.attr.actionBarStyle, 0);
        setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
        a.recycle();

        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 booleanshowOverflowMenu()

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