Example usage for android.view MenuInflater MenuInflater

List of usage examples for android.view MenuInflater MenuInflater

Introduction

In this page you can find the example usage for android.view MenuInflater MenuInflater.

Prototype

public MenuInflater(Context context) 

Source Link

Document

Constructs a menu inflater.

Usage

From source file:com.jwork.dhammapada.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    log.v(this, "onCreateOptionsMenu()");
    new MenuInflater(this).inflate(R.menu.menu_main, menu);
    return true;//from   w  w  w  .j ava  2s .c om
}

From source file:com.mrchandler.disableprox.ui.SensorSettingsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = new MenuInflater(this);
    inflater.inflate(R.menu.settings_menu, menu);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.orangelabs.rcs.ri.messaging.chat.group.GroupChatList.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = new MenuInflater(getApplicationContext());
    inflater.inflate(R.menu.menu_log, menu);
    return true;/*  ww w . java 2s  . co m*/
}

From source file:org.tigase.mobile.roster.RosterFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    final Long id = extractId(menuInfo);

    if (id != null && id != -1) {
        RosterItem r = getJid(id);//from   w w  w .  j  a  v  a  2s .  c o  m
        final boolean sessionEstablished = r != null && isSessionEstablished(r.getSessionObject());

        MenuInflater m = new MenuInflater(getActivity());
        try {
            Presence p = r.getSessionObject().getPresence().getBestPresence(r.getJid());
            if (p != null && p.getType() == null) {
                SubMenu sm = menu.addSubMenu(R.id.contactsOnlineGroup, Menu.NONE, Menu.NONE, "Chat with");
                prepareResources(sm, id);
            }
        } catch (Exception e) {
        }
        m.inflate(R.menu.roster_context_menu, menu);

        JaxmppCore jaxmpp = this.getMulti().get(r.getSessionObject());
        if (jaxmpp != null && sessionEstablished) {
            GeolocationModule module = jaxmpp.getModule(GeolocationModule.class);
            if (module != null) {
                ContentValues location = module.getLocationForJid(r.getJid());
                if (location != null) {
                    Double lat = location.getAsDouble(GeolocationTableMetaData.FIELD_LAT);
                    Double lon = location.getAsDouble(GeolocationTableMetaData.FIELD_LON);
                    String uriStr = null;
                    if (lon == null || lat == null) {
                        String str = "";
                        String val = location.getAsString(GeolocationTableMetaData.FIELD_STREET);
                        Log.v(TAG, "Street = " + String.valueOf(val));
                        if (val != null) {
                            str += val;
                        }
                        val = location.getAsString(GeolocationTableMetaData.FIELD_LOCALITY);
                        Log.v(TAG, "Locality = " + String.valueOf(val));
                        if (val != null) {
                            if (!isEmpty(str)) {
                                str += " ";
                            }
                            str += val;
                        }
                        val = location.getAsString(GeolocationTableMetaData.FIELD_COUNTRY);
                        Log.v(TAG, "Country = " + String.valueOf(val));
                        if (val != null) {
                            if (!isEmpty(str)) {
                                str += " ";
                            }
                            str += val;
                        }

                        if (!isEmpty(str)) {
                            str = str.replace(' ', '+');
                            uriStr = "geo:0,0?q=" + str;
                        }
                    } else {
                        Log.v(TAG, "latitude = " + String.valueOf(lat));
                        Log.v(TAG, "longitude = " + String.valueOf(lon));
                        uriStr = "geo:" + String.valueOf(lat) + "," + String.valueOf(lon) + "?z=14";
                    }
                    if (uriStr != null) {
                        uriStr += "(" + RosterDisplayTools.getDisplayName(r) + ")";
                        Log.v(TAG, "created geolocation uri = " + uriStr);
                        Uri uri = Uri.parse(uriStr);
                        MenuItem item = menu.add(R.string.geolocation_show);
                        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                        item.setIntent(intent);
                    }
                }
            }
        }

        menu.setGroupVisible(R.id.contactsOnlineGroup, sessionEstablished);
    }
}

From source file:org.tigase.mobile.chat.ChatHistoryFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater m = new MenuInflater(getActivity());
    m.inflate(R.menu.chat_context_menu, menu);
}

From source file:com.liquid.wallpapers.free.ScroidWallpaperGallery.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (this.selectedWallpaper == null || !(v instanceof Gallery)) {
        return;// w w  w  .j a  va  2  s.c om
    }

    MenuInflater menuInflater = new MenuInflater(this);
    menuInflater.inflate(R.menu.gallery_context_menu, menu);

    if (this.favouriteDAO.isFavourite(this.selectedWallpaper.getId())) {
        menu.findItem(R.id.galleryRemoveFavouriteMenuItem).setVisible(true);
    } else {
        menu.findItem(R.id.galleryAddFavouriteMenuItem).setVisible(true);
    }
}

From source file:com.liquid.wallpapers.free.ScroidWallpaperGallery.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = new MenuInflater(this);
    menuInflater.inflate(R.menu.main_menu, menu);

    return true;/*from   www.  j a  va 2s .c o m*/
}

From source file:uk.co.massimocarli.friendfence.location.FenceSessionListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = new MenuInflater(getActivity());
    inflater.inflate(R.menu.fence_session_context, menu);
}

From source file:com.rks.musicx.ui.activities.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = new MenuInflater(MainActivity.this);
    menuInflater.inflate(R.menu.main, menu);
    return true;//ww w .j a v a  2s. c o m
}

From source file:org.mozilla.gecko.home.TopSitesPanel.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    if (menuInfo == null) {
        return;/*from  www .  j  av a2 s. co m*/
    }

    if (!(menuInfo instanceof TopSitesGridContextMenuInfo)) {
        // Long pressed item was not a Top Sites GridView item. Superclass
        // can handle this.
        super.onCreateContextMenu(menu, view, menuInfo);
        return;
    }

    // Long pressed item was a Top Sites GridView item, handle it.
    MenuInflater inflater = new MenuInflater(view.getContext());
    inflater.inflate(R.menu.home_contextmenu, menu);

    // Hide unused menu items.
    menu.findItem(R.id.home_edit_bookmark).setVisible(false);

    TopSitesGridContextMenuInfo info = (TopSitesGridContextMenuInfo) menuInfo;
    menu.setHeaderTitle(info.getDisplayTitle());

    if (info.type != TopSites.TYPE_BLANK) {
        if (info.type == TopSites.TYPE_PINNED) {
            menu.findItem(R.id.top_sites_pin).setVisible(false);
        } else {
            menu.findItem(R.id.top_sites_unpin).setVisible(false);
        }
    } else {
        menu.findItem(R.id.home_open_new_tab).setVisible(false);
        menu.findItem(R.id.home_open_private_tab).setVisible(false);
        menu.findItem(R.id.top_sites_pin).setVisible(false);
        menu.findItem(R.id.top_sites_unpin).setVisible(false);
    }

    if (!StringUtils.isShareableUrl(info.url) || GeckoProfile.get(getActivity()).inGuestMode()) {
        menu.findItem(R.id.home_share).setVisible(false);
    }

    if (!RestrictedProfiles.isAllowed(view.getContext(), Restriction.DISALLOW_PRIVATE_BROWSING)) {
        menu.findItem(R.id.home_open_private_tab).setVisible(false);
    }
}