AbsActionBarViewpublic 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 | mPopupContextContext 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 void | animateToVisibility(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 boolean | canShowOverflowMenu()
return isOverflowReserved() && getVisibility() == VISIBLE;
| public void | dismissPopupMenus()
if (mActionMenuPresenter != null) {
mActionMenuPresenter.dismissPopupMenus();
}
| public int | getAnimatedVisibility()
if (mVisibilityAnim != null) {
return mVisAnimListener.mFinalVisibility;
}
return getVisibility();
| public int | getContentHeight()
return mContentHeight;
| public boolean | hideOverflowMenu()
if (mActionMenuPresenter != null) {
return mActionMenuPresenter.hideOverflowMenu();
}
return false;
| public boolean | isOverflowMenuShowPending()
if (mActionMenuPresenter != null) {
return mActionMenuPresenter.isOverflowMenuShowPending();
}
return false;
| public boolean | isOverflowMenuShowing()
if (mActionMenuPresenter != null) {
return mActionMenuPresenter.isOverflowMenuShowing();
}
return false;
| public boolean | isOverflowReserved()
return mActionMenuPresenter != null && mActionMenuPresenter.isOverflowReserved();
| protected int | measureChildView(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 int | next(int x, int val, boolean isRtl)
return isRtl ? x - val : x + val;
| protected void | onConfigurationChanged(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 int | positionChild(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 void | postShowOverflowMenu()
post(new Runnable() {
public void run() {
showOverflowMenu();
}
});
| public void | setContentHeight(int height)
mContentHeight = height;
requestLayout();
| public void | setSplitToolbar(boolean split)Sets whether the bar should be split right now, no questions asked.
mSplitActionBar = split;
| public void | setSplitView(android.view.ViewGroup splitView)
mSplitView = splitView;
| public void | setSplitWhenNarrow(boolean splitWhenNarrow)Sets whether the bar should split if we enter a narrow screen configuration.
mSplitWhenNarrow = splitWhenNarrow;
| public void | setVisibility(int visibility)
if (visibility != getVisibility()) {
if (mVisibilityAnim != null) {
mVisibilityAnim.end();
}
super.setVisibility(visibility);
}
| public boolean | showOverflowMenu()
if (mActionMenuPresenter != null) {
return mActionMenuPresenter.showOverflowMenu();
}
return false;
|
|