Search in sources :

Example 6 with BridgeMenuItemImpl

use of com.android.internal.view.menu.BridgeMenuItemImpl in project android_frameworks_base by DirtyUnicorns.

the class MenuInflater_Delegate method registerMenu.

@LayoutlibDelegate
static /*package*/
void registerMenu(MenuInflater thisInflater, MenuItem menuItem, AttributeSet attrs) {
    if (menuItem instanceof BridgeMenuItemImpl) {
        Context context = thisInflater.getContext();
        context = BridgeContext.getBaseContext(context);
        if (context instanceof BridgeContext) {
            Object viewKey = BridgeInflater.getViewKeyFromParser(attrs, ((BridgeContext) context), null, false);
            ((BridgeMenuItemImpl) menuItem).setViewCookie(viewKey);
            return;
        }
    }
    // This means that Bridge did not take over the instantiation of some object properly.
    // This is most likely a bug in the LayoutLib code.
    Bridge.getLog().warning(LayoutLog.TAG_BROKEN, "Action Bar Menu rendering may be incorrect.", null);
}
Also used : BridgeMenuItemImpl(com.android.internal.view.menu.BridgeMenuItemImpl) Context(android.content.Context) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 7 with BridgeMenuItemImpl

use of com.android.internal.view.menu.BridgeMenuItemImpl in project android_frameworks_base by AOSPA.

the class RenderSessionImpl method getViewKey.

/* (non-Javadoc)
     * The cookie for menu items are stored in menu item and not in the map from View stored in
     * BridgeContext.
     */
@Nullable
private Object getViewKey(View view) {
    BridgeContext context = getContext();
    if (!(view instanceof MenuView.ItemView)) {
        return context.getViewKey(view);
    }
    MenuItemImpl menuItem;
    if (view instanceof ActionMenuItemView) {
        menuItem = ((ActionMenuItemView) view).getItemData();
    } else if (view instanceof ListMenuItemView) {
        menuItem = ((ListMenuItemView) view).getItemData();
    } else if (view instanceof IconMenuItemView) {
        menuItem = ((IconMenuItemView) view).getItemData();
    } else {
        menuItem = null;
    }
    if (menuItem instanceof BridgeMenuItemImpl) {
        return ((BridgeMenuItemImpl) menuItem).getViewCookie();
    }
    return null;
}
Also used : BridgeMenuItemImpl(com.android.internal.view.menu.BridgeMenuItemImpl) MenuItemImpl(com.android.internal.view.menu.MenuItemImpl) BridgeMenuItemImpl(com.android.internal.view.menu.BridgeMenuItemImpl) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView) IconMenuItemView(com.android.internal.view.menu.IconMenuItemView) ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) IconMenuItemView(com.android.internal.view.menu.IconMenuItemView) ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView) Nullable(android.annotation.Nullable)

Example 8 with BridgeMenuItemImpl

use of com.android.internal.view.menu.BridgeMenuItemImpl in project android_frameworks_base by ResurrectionRemix.

the class MenuInflater_Delegate method registerMenu.

@LayoutlibDelegate
static /*package*/
void registerMenu(MenuInflater thisInflater, MenuItem menuItem, AttributeSet attrs) {
    if (menuItem instanceof BridgeMenuItemImpl) {
        Context context = thisInflater.getContext();
        context = BridgeContext.getBaseContext(context);
        if (context instanceof BridgeContext) {
            Object viewKey = BridgeInflater.getViewKeyFromParser(attrs, ((BridgeContext) context), null, false);
            ((BridgeMenuItemImpl) menuItem).setViewCookie(viewKey);
            return;
        }
    }
    // This means that Bridge did not take over the instantiation of some object properly.
    // This is most likely a bug in the LayoutLib code.
    Bridge.getLog().warning(LayoutLog.TAG_BROKEN, "Action Bar Menu rendering may be incorrect.", null);
}
Also used : BridgeMenuItemImpl(com.android.internal.view.menu.BridgeMenuItemImpl) Context(android.content.Context) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 9 with BridgeMenuItemImpl

use of com.android.internal.view.menu.BridgeMenuItemImpl in project android_frameworks_base by ResurrectionRemix.

the class RenderSessionImpl method getViewKey.

/* (non-Javadoc)
     * The cookie for menu items are stored in menu item and not in the map from View stored in
     * BridgeContext.
     */
@Nullable
private Object getViewKey(View view) {
    BridgeContext context = getContext();
    if (!(view instanceof MenuView.ItemView)) {
        return context.getViewKey(view);
    }
    MenuItemImpl menuItem;
    if (view instanceof ActionMenuItemView) {
        menuItem = ((ActionMenuItemView) view).getItemData();
    } else if (view instanceof ListMenuItemView) {
        menuItem = ((ListMenuItemView) view).getItemData();
    } else if (view instanceof IconMenuItemView) {
        menuItem = ((IconMenuItemView) view).getItemData();
    } else {
        menuItem = null;
    }
    if (menuItem instanceof BridgeMenuItemImpl) {
        return ((BridgeMenuItemImpl) menuItem).getViewCookie();
    }
    return null;
}
Also used : BridgeMenuItemImpl(com.android.internal.view.menu.BridgeMenuItemImpl) MenuItemImpl(com.android.internal.view.menu.MenuItemImpl) BridgeMenuItemImpl(com.android.internal.view.menu.BridgeMenuItemImpl) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView) IconMenuItemView(com.android.internal.view.menu.IconMenuItemView) ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) IconMenuItemView(com.android.internal.view.menu.IconMenuItemView) ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView) Nullable(android.annotation.Nullable)

Example 10 with BridgeMenuItemImpl

use of com.android.internal.view.menu.BridgeMenuItemImpl in project android_frameworks_base by crdroidandroid.

the class RenderSessionImpl method getViewKey.

/* (non-Javadoc)
     * The cookie for menu items are stored in menu item and not in the map from View stored in
     * BridgeContext.
     */
@Nullable
private Object getViewKey(View view) {
    BridgeContext context = getContext();
    if (!(view instanceof MenuView.ItemView)) {
        return context.getViewKey(view);
    }
    MenuItemImpl menuItem;
    if (view instanceof ActionMenuItemView) {
        menuItem = ((ActionMenuItemView) view).getItemData();
    } else if (view instanceof ListMenuItemView) {
        menuItem = ((ListMenuItemView) view).getItemData();
    } else if (view instanceof IconMenuItemView) {
        menuItem = ((IconMenuItemView) view).getItemData();
    } else {
        menuItem = null;
    }
    if (menuItem instanceof BridgeMenuItemImpl) {
        return ((BridgeMenuItemImpl) menuItem).getViewCookie();
    }
    return null;
}
Also used : BridgeMenuItemImpl(com.android.internal.view.menu.BridgeMenuItemImpl) MenuItemImpl(com.android.internal.view.menu.MenuItemImpl) BridgeMenuItemImpl(com.android.internal.view.menu.BridgeMenuItemImpl) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView) IconMenuItemView(com.android.internal.view.menu.IconMenuItemView) ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) IconMenuItemView(com.android.internal.view.menu.IconMenuItemView) ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView) Nullable(android.annotation.Nullable)

Aggregations

BridgeMenuItemImpl (com.android.internal.view.menu.BridgeMenuItemImpl)10 BridgeContext (com.android.layoutlib.bridge.android.BridgeContext)10 Nullable (android.annotation.Nullable)5 Context (android.content.Context)5 ActionMenuItemView (com.android.internal.view.menu.ActionMenuItemView)5 IconMenuItemView (com.android.internal.view.menu.IconMenuItemView)5 ListMenuItemView (com.android.internal.view.menu.ListMenuItemView)5 MenuItemImpl (com.android.internal.view.menu.MenuItemImpl)5 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)5