本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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;
}
示例5: setMenu
import android.support.v7.view.menu.MenuPresenter; //导入依赖的package包/类
public void setMenu(Menu menu, MenuPresenter.Callback cb) {
pullChildren();
this.mDecorToolbar.setMenu(menu, cb);
}
示例6: setMenuCallbacks
import android.support.v7.view.menu.MenuPresenter; //导入依赖的package包/类
public void setMenuCallbacks(MenuPresenter.Callback actionMenuPresenterCallback, MenuBuilder.Callback menuBuilderCallback) {
this.mToolbar.setMenuCallbacks(actionMenuPresenterCallback, menuBuilderCallback);
}
示例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;
}
示例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();
}
}
示例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;
}