Search in sources :

Example 1 with MenuBuilder

use of com.smartandroid.sa.sherlock.internal.view.menu.MenuBuilder in project SmartAndroidSource by jaychou2012.

the class ActionBarSherlockCompat method initializePanelMenu.

private boolean initializePanelMenu() {
    // getContext();
    Context context = mActivity;
    // for it.
    if (wActionBar != null) {
        TypedValue outValue = new TypedValue();
        Resources.Theme currentTheme = context.getTheme();
        currentTheme.resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true);
        final int targetThemeRes = outValue.resourceId;
        if (targetThemeRes != 0) /*
									 * && context.getThemeResId() !=
									 * targetThemeRes
									 */
        {
            context = new ContextThemeWrapper(context, targetThemeRes);
        }
    }
    mMenu = new MenuBuilder(context);
    mMenu.setCallback(this);
    return true;
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) Resources(android.content.res.Resources) MenuBuilder(com.smartandroid.sa.sherlock.internal.view.menu.MenuBuilder) TypedValue(android.util.TypedValue)

Example 2 with MenuBuilder

use of com.smartandroid.sa.sherlock.internal.view.menu.MenuBuilder in project SmartAndroidSource by jaychou2012.

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(getResources().getIdentifier("abs__action_menu_presenter", "id", c.getPackageName()));
        // 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(), getResources().getIdentifier("abs__action_bar_expanded_action_views_exclusive", "bool", c.getPackageName())));
        // 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.smartandroid.sa.sherlock.internal.view.menu.ActionMenuView) MenuBuilder(com.smartandroid.sa.sherlock.internal.view.menu.MenuBuilder) SubMenuBuilder(com.smartandroid.sa.sherlock.internal.view.menu.SubMenuBuilder) ActionMenuPresenter(com.smartandroid.sa.sherlock.internal.view.menu.ActionMenuPresenter)

Example 3 with MenuBuilder

use of com.smartandroid.sa.sherlock.internal.view.menu.MenuBuilder in project SmartAndroidSource by jaychou2012.

the class ActionBarContextView method initForMode.

public void initForMode(final ActionMode mode) {
    if (mClose == null) {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        mClose = (NineLinearLayout) inflater.inflate(getResources().getIdentifier("abs__action_mode_close_item", "layout", mContext.getPackageName()), this, false);
        // R.layout.abs__action_mode_close_item, this, false);
        addView(mClose);
    } else if (mClose.getParent() == null) {
        addView(mClose);
    }
    View closeButton = mClose.findViewById(getResources().getIdentifier("abs__action_mode_close_button", "id", mContext.getPackageName()));
    // .findViewById(R.id.abs__action_mode_close_button);
    closeButton.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            mode.finish();
        }
    });
    final MenuBuilder menu = (MenuBuilder) mode.getMenu();
    if (mActionMenuPresenter != null) {
        mActionMenuPresenter.dismissPopupMenus();
    }
    mActionMenuPresenter = new ActionMenuPresenter(mContext);
    mActionMenuPresenter.setReserveOverflow(true);
    final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    if (!mSplitActionBar) {
        menu.addMenuPresenter(mActionMenuPresenter);
        mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        mMenuView.setBackgroundDrawable(null);
        addView(mMenuView, layoutParams);
    } else {
        // 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;
        layoutParams.height = mContentHeight;
        menu.addMenuPresenter(mActionMenuPresenter);
        mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        mMenuView.setBackgroundDrawable(mSplitBackground);
        mSplitView.addView(mMenuView, layoutParams);
    }
    mAnimateInOnLayout = true;
}
Also used : LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) View(android.view.View) ActionMenuView(com.smartandroid.sa.sherlock.internal.view.menu.ActionMenuView) MenuBuilder(com.smartandroid.sa.sherlock.internal.view.menu.MenuBuilder) ActionMenuPresenter(com.smartandroid.sa.sherlock.internal.view.menu.ActionMenuPresenter)

Aggregations

MenuBuilder (com.smartandroid.sa.sherlock.internal.view.menu.MenuBuilder)3 ActionMenuPresenter (com.smartandroid.sa.sherlock.internal.view.menu.ActionMenuPresenter)2 ActionMenuView (com.smartandroid.sa.sherlock.internal.view.menu.ActionMenuView)2 Context (android.content.Context)1 Resources (android.content.res.Resources)1 TypedValue (android.util.TypedValue)1 ContextThemeWrapper (android.view.ContextThemeWrapper)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 TextView (android.widget.TextView)1 SubMenuBuilder (com.smartandroid.sa.sherlock.internal.view.menu.SubMenuBuilder)1