当前位置: 首页>>代码示例>>Java>>正文


Java MenuPresenter类代码示例

本文整理汇总了Java中android.support.v7.view.menu.MenuPresenter的典型用法代码示例。如果您正苦于以下问题:Java MenuPresenter类的具体用法?Java MenuPresenter怎么用?Java MenuPresenter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MenuPresenter类属于android.support.v7.view.menu包,在下文中一共展示了MenuPresenter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import android.support.v7.view.menu.MenuPresenter; //导入依赖的package包/类
@Override
public void draw(@NonNull View view, @NonNull Object value) {
    Toolbar toolbar = (Toolbar) view;
    int themeId = (int) value;
    try {
        ActionMenuView actionMenuView = (ActionMenuView) sActionMenuViewField.get(toolbar);
        if ( actionMenuView == null ){
            toolbar.getContext().setTheme(themeId);
        } else {
            MenuPresenter presenter = (MenuPresenter) sPresenterField.get(actionMenuView);
            Context context = (Context) sContextField.get(presenter);
            context.setTheme(themeId);
        }

    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    toolbar.setPopupTheme((Integer) value);
}
 
开发者ID:ashqal,项目名称:NightOwl,代码行数:20,代码来源:ToolbarHandler.java

示例2: getListMenuView

import android.support.v7.view.menu.MenuPresenter; //导入依赖的package包/类
MenuView getListMenuView(MenuPresenter.Callback cb) {
    if (this.menu == null) {
        return null;
    }
    if (this.listMenuPresenter == null) {
        this.listMenuPresenter = new ListMenuPresenter(this.listPresenterContext, R.layout.abc_list_menu_item_layout);
        this.listMenuPresenter.setCallback(cb);
        this.menu.addMenuPresenter(this.listMenuPresenter);
    }
    return this.listMenuPresenter.getMenuView(this.decorView);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:AppCompatDelegateImplV7.java

示例3: setMenu

import android.support.v7.view.menu.MenuPresenter; //导入依赖的package包/类
public void setMenu(Menu menu, MenuPresenter.Callback cb) {
    if (this.mActionMenuPresenter == null) {
        this.mActionMenuPresenter = new ActionMenuPresenter(this.mToolbar.getContext());
        this.mActionMenuPresenter.setId(R.id.action_menu_presenter);
    }
    this.mActionMenuPresenter.setCallback(cb);
    this.mToolbar.setMenu((MenuBuilder) menu, this.mActionMenuPresenter);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:ToolbarWidgetWrapper.java

示例4: performItemAction

import android.support.v7.view.menu.MenuPresenter; //导入依赖的package包/类
public boolean performItemAction(android.view.MenuItem item, MenuPresenter preferredPresenter, int flags) {
    MenuItem itemImpl = (MenuItem) item;

    if (itemImpl == null || !itemImpl.isEnabled()) {
        return false;
    }

    itemImpl.performAction();

    return true;
}
 
开发者ID:ZieIony,项目名称:Carbon,代码行数:12,代码来源:Menu.java

示例5: setMenu

import android.support.v7.view.menu.MenuPresenter; //导入依赖的package包/类
public void setMenu(Menu menu, MenuPresenter.Callback cb) {
    pullChildren();
    this.mDecorToolbar.setMenu(menu, cb);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:5,代码来源:ActionBarOverlayLayout.java

示例6: setMenuCallbacks

import android.support.v7.view.menu.MenuPresenter; //导入依赖的package包/类
public void setMenuCallbacks(MenuPresenter.Callback actionMenuPresenterCallback, MenuBuilder.Callback menuBuilderCallback) {
    this.mToolbar.setMenuCallbacks(actionMenuPresenterCallback, menuBuilderCallback);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:ToolbarWidgetWrapper.java

示例7: ATEMenuPresenterCallback

import android.support.v7.view.menu.MenuPresenter; //导入依赖的package包/类
public ATEMenuPresenterCallback(Activity context, String key, MenuPresenter.Callback parentCb, Toolbar toolbar) {
    mContext = context;
    mKey = key;
    mParentCb = parentCb;
    mToolbar = toolbar;
}
 
开发者ID:cseshaiban,项目名称:app-theme-engine-master,代码行数:7,代码来源:ATEMenuPresenterCallback.java

示例8: setToolbarContentColor

import android.support.v7.view.menu.MenuPresenter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void setToolbarContentColor(@NonNull Context context, Toolbar toolbar, @Nullable Menu menu, final @ColorInt int toolbarContentColor, final @ColorInt int titleTextColor, final @ColorInt int subtitleTextColor, final @ColorInt int menuWidgetColor) {
    if (toolbar == null) return;

    if (menu == null) {
        menu = toolbar.getMenu();
    }

    toolbar.setTitleTextColor(titleTextColor);
    toolbar.setSubtitleTextColor(subtitleTextColor);

    if (toolbar.getNavigationIcon() != null) {
        // Tint the toolbar navigation icon (e.g. back, drawer, etc.)
        toolbar.setNavigationIcon(TintHelper.createTintedDrawable(toolbar.getNavigationIcon(), toolbarContentColor));
    }

    InternalToolbarContentTintUtil.tintMenu(toolbar, menu, toolbarContentColor);
    InternalToolbarContentTintUtil.applyOverflowMenuTint(context, toolbar, menuWidgetColor);

    if (context instanceof Activity) {
        InternalToolbarContentTintUtil.setOverflowButtonColor((Activity) context, toolbarContentColor);
    }

    try {
        // Tint immediate overflow menu items
        final Field menuField = Toolbar.class.getDeclaredField("mMenuBuilderCallback");
        menuField.setAccessible(true);
        final Field presenterField = Toolbar.class.getDeclaredField("mActionMenuPresenterCallback");
        presenterField.setAccessible(true);
        final Field menuViewField = Toolbar.class.getDeclaredField("mMenuView");
        menuViewField.setAccessible(true);

        final MenuPresenter.Callback currentPresenterCb = (MenuPresenter.Callback) presenterField.get(toolbar);
        if (!(currentPresenterCb instanceof ATHMenuPresenterCallback)) {
            final ATHMenuPresenterCallback newPresenterCb = new ATHMenuPresenterCallback(context, menuWidgetColor, currentPresenterCb, toolbar);
            final MenuBuilder.Callback currentMenuCb = (MenuBuilder.Callback) menuField.get(toolbar);
            toolbar.setMenuCallbacks(newPresenterCb, currentMenuCb);
            ActionMenuView menuView = (ActionMenuView) menuViewField.get(toolbar);
            if (menuView != null)
                menuView.setMenuCallbacks(newPresenterCb, currentMenuCb);
        }

        // OnMenuItemClickListener to tint submenu items
        final Field menuItemClickListener = Toolbar.class.getDeclaredField("mOnMenuItemClickListener");
        menuItemClickListener.setAccessible(true);
        Toolbar.OnMenuItemClickListener currentClickListener = (Toolbar.OnMenuItemClickListener) menuItemClickListener.get(toolbar);
        if (!(currentClickListener instanceof ATHOnMenuItemClickListener)) {
            final ATHOnMenuItemClickListener newClickListener = new ATHOnMenuItemClickListener(context, menuWidgetColor, currentClickListener, toolbar);
            toolbar.setOnMenuItemClickListener(newClickListener);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:punchup,项目名称:Superuser-UI,代码行数:55,代码来源:ToolbarContentTintHelper.java

示例9: ATHMenuPresenterCallback

import android.support.v7.view.menu.MenuPresenter; //导入依赖的package包/类
public ATHMenuPresenterCallback(Context context, final @ColorInt int color, MenuPresenter.Callback parentCb, Toolbar toolbar) {
    mContext = context;
    mColor = color;
    mParentCb = parentCb;
    mToolbar = toolbar;
}
 
开发者ID:punchup,项目名称:Superuser-UI,代码行数:7,代码来源:ToolbarContentTintHelper.java


注:本文中的android.support.v7.view.menu.MenuPresenter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。