Example usage for android.view Menu FIRST

List of usage examples for android.view Menu FIRST

Introduction

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

Prototype

int FIRST

To view the source code for android.view Menu FIRST.

Click Source Link

Document

First value for group and item identifier integers.

Usage

From source file:org.alfresco.mobile.android.application.fragments.user.UserProfileFragment.java

private void getMenu(Menu menu, int mode) {
    MenuItem mi = null;/*  w  w  w  .j  a  v  a 2s .  c om*/
    switch (mode) {
    case MODE_CALL:
        if (person.getTelephoneNumber() != null && !person.getTelephoneNumber().isEmpty()) {
            mi = menu.add(Menu.NONE, R.id.menu_user_phone, Menu.FIRST + 6, person.getTelephoneNumber());
            mi.setIcon(R.drawable.ic_call);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (person.getMobileNumber() != null && !person.getMobileNumber().isEmpty()) {
            mi = menu.add(Menu.NONE, R.id.menu_user_mobile, Menu.FIRST + 7, person.getMobileNumber());
            mi.setIcon(R.drawable.ic_call);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (person.getCompany() != null && person.getCompany().getTelephoneNumber() != null
                && !person.getCompany().getTelephoneNumber().isEmpty()) {
            mi = menu.add(Menu.NONE, R.id.menu_user_company_phone, Menu.FIRST + 5,
                    person.getCompany().getTelephoneNumber());
            mi.setIcon(R.drawable.ic_call);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
        break;
    case MODE_SKYPE:
        mi = menu.add(Menu.NONE, R.id.menu_user_chat, Menu.FIRST, R.string.start_chat);
        mi.setIcon(R.drawable.ic_im);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

        mi = menu.add(Menu.NONE, R.id.menu_user_call, Menu.FIRST + 1, R.string.start_call);
        mi.setIcon(R.drawable.ic_call);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

        mi = menu.add(Menu.NONE, R.id.menu_user_videocall, Menu.FIRST + 2, R.string.start_video_call);
        mi.setIcon(R.drawable.ic_videos);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        break;
    case MODE_EMAIL:
        if (person.getEmail() != null && !person.getEmail().isEmpty()) {
            mi = menu.add(Menu.NONE, R.id.menu_user_email, Menu.FIRST + 3, person.getEmail());
            mi.setIcon(R.drawable.ic_send_mail);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (person.getCompany() != null && person.getCompany().getEmail() != null
                && !person.getCompany().getEmail().isEmpty()) {
            mi = menu.add(Menu.NONE, R.id.menu_user_company_email, Menu.FIRST + 4,
                    person.getCompany().getEmail());
            mi.setIcon(R.drawable.ic_send_mail);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
        break;

    default:
        break;
    }

}

From source file:org.alfresco.mobile.android.application.fragments.person.PersonProfileFragment.java

private void getMenu(Menu menu, int mode) {
    MenuItem mi = null;/*from   w  ww .j  a  va 2s  .c  o  m*/
    switch (mode) {
    case MODE_CALL:
        if (person.getTelephoneNumber() != null && !person.getTelephoneNumber().isEmpty()) {
            mi = menu.add(Menu.NONE, MenuActionItem.MENU_TEL, Menu.FIRST + MenuActionItem.MENU_TEL,
                    person.getTelephoneNumber());
            mi.setIcon(R.drawable.ic_call);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (person.getMobileNumber() != null && !person.getMobileNumber().isEmpty()) {
            mi = menu.add(Menu.NONE, MenuActionItem.MENU_MOBILE, Menu.FIRST + MenuActionItem.MENU_MOBILE,
                    person.getMobileNumber());
            mi.setIcon(R.drawable.ic_call);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (person.getCompany() != null && person.getCompany().getTelephoneNumber() != null
                && !person.getCompany().getTelephoneNumber().isEmpty()) {
            mi = menu.add(Menu.NONE, MenuActionItem.MENU_COMPANY_TEL,
                    Menu.FIRST + MenuActionItem.MENU_COMPANY_TEL, person.getCompany().getTelephoneNumber());
            mi.setIcon(R.drawable.ic_call);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
        break;
    case MODE_SKYPE:
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_CHAT, Menu.FIRST + MenuActionItem.MENU_CHAT,
                R.string.start_chat);
        mi.setIcon(R.drawable.ic_im);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

        mi = menu.add(Menu.NONE, MenuActionItem.MENU_CALL, Menu.FIRST + MenuActionItem.MENU_CALL,
                R.string.start_call);
        mi.setIcon(R.drawable.ic_call);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

        mi = menu.add(Menu.NONE, MenuActionItem.MENU_VIDEOCALL, Menu.FIRST + MenuActionItem.MENU_VIDEOCALL,
                R.string.start_video_call);
        mi.setIcon(R.drawable.ic_videocall);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        break;
    case MODE_EMAIL:
        if (person.getEmail() != null && !person.getEmail().isEmpty()) {
            mi = menu.add(Menu.NONE, MenuActionItem.MENU_EMAIL, Menu.FIRST + MenuActionItem.MENU_EMAIL,
                    person.getEmail());
            mi.setIcon(R.drawable.ic_send_mail);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (person.getCompany() != null && person.getCompany().getEmail() != null
                && !person.getCompany().getEmail().isEmpty()) {
            mi = menu.add(Menu.NONE, MenuActionItem.MENU_COMPANY_EMAIL,
                    Menu.FIRST + MenuActionItem.MENU_COMPANY_EMAIL, person.getCompany().getEmail());
            mi.setIcon(R.drawable.ic_send_mail);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
        break;

    default:
        break;
    }

}

From source file:edu.cmu.android.restaurant.MapFragment.java

/**
 * Menu - include 4 items 1. Camera : click to make a photo 2. Coupon :
 * click to find the coupon of the restaurant 3. About : The developer's
 * information/*www  . ja  v a  2 s. c om*/
 * */

public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    super.onCreateOptionsMenu(menu, inflater);
    // 1.group, 2.ID, 3.order, 4.txt
    menu.add(Menu.NONE, Menu.FIRST + 1, 1, "Camera").setIcon(android.R.drawable.ic_menu_camera);
    menu.add(Menu.NONE, Menu.FIRST + 2, 2, "Coupon").setIcon(R.drawable.ic_menu_emoticons);
    menu.add(Menu.NONE, Menu.FIRST + 3, 3, "About").setIcon(android.R.drawable.ic_menu_myplaces);

}

From source file:edu.cmu.android.restaurant.MapFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    /* menu : camera */
    case Menu.FIRST + 1:
        try {/*  w  w w. ja va  2s.  c  o  m*/
            Intent i = new Intent("android.media.action.IMAGE_CAPTURE");
            startActivityForResult(i, Activity.DEFAULT_KEYS_DIALER);
        } catch (Exception e) {
            Log.d("Detail", "Cemara onClick error.");
        } finally {
            if (getActivity().getResources()
                    .getConfiguration().orientation != Configuration.ORIENTATION_PORTRAIT) {
                getActivity().setRequestedOrientation(Configuration.ORIENTATION_PORTRAIT);
            }
        }
        break;

    /* menu : coupon */
    case Menu.FIRST + 2:
        /* display the deal in a dialog */
        findDeal();
        dealDisplay();
        /* audio play */
        MediaPlayer mp = MediaPlayer.create(getActivity(), R.raw.coupon_audio);
        mp.seekTo(0);
        mp.start();
        break;

    /* Menu : about */
    case Menu.FIRST + 3:
        Builder builder3 = new AlertDialog.Builder(getActivity());
        builder3.setTitle("About US");
        builder3.setMessage(ABOUT_CONTENT);
        builder3.setPositiveButton("Return", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        }).show();
        break;
    }
    return false;

}

From source file:com.fabernovel.alertevoirie.HomeActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, MENU_CREDITS, Menu.FIRST, R.string.menu_credits)
            .setIcon(android.R.drawable.ic_menu_info_details);
    return super.onCreateOptionsMenu(menu);
}

From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.FileExplorerAdapter.java

public void getMenu(Menu menu, File f) {
    MenuItem mi;/*from  w w w .ja  va  2  s .  c  o m*/

    if (f.isFile()) {
        mi = menu.add(Menu.NONE, R.id.menu_action_share, Menu.FIRST, R.string.share);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

        mi = menu.add(Menu.NONE, R.id.menu_upload, Menu.FIRST + 30, R.string.upload);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    if (f.canWrite() && downloadPath != null && f.getPath().startsWith(downloadPath)) {
        mi = menu.add(Menu.NONE, R.id.menu_action_edit, Menu.FIRST + 50, R.string.action_rename);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

        mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 100, R.string.delete);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    if (DataProtectionManager.getInstance(getContext()).isEncryptionEnable()) {
        if (DataProtectionManager.getInstance(getContext()).isEncrypted(f.getPath())) {
            mi = menu.add(Menu.NONE, R.id.menu_file_decrypt, Menu.FIRST + 70, R.string.decrypt_action);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        } else {
            mi = menu.add(Menu.NONE, R.id.menu_file_encrypt, Menu.FIRST + 70, R.string.encrypt_action);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }
    }

}

From source file:com.cubic9.android.droidglove.Main.java

@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
    super.onCreateOptionsMenu(menu);

    menu.add(0, Menu.FIRST, 0, R.string.menu_settings).setIcon(android.R.drawable.ic_menu_preferences);

    return true;// w w w .  j a  v  a2  s  .  c o  m
}

From source file:com.cubic9.android.droidglove.Main.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case Menu.FIRST:
        Intent intent = new Intent(Main.this, Settings.class);
        startActivityForResult(intent, 0);
        return true;
    }//  w w w . ja v a2s. c  o  m

    return super.onOptionsItemSelected(item);
}

From source file:org.alfresco.mobile.android.application.fragments.preferences.AccountSettingsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();// w  w w  .  j  a  v a  2s  . c  o  m
    MenuItem mi = menu.add(Menu.NONE, R.id.menu_account_delete, Menu.FIRST + 10, R.string.delete);
    mi.setIcon(R.drawable.ic_clear_grey);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    if (SessionManager.getInstance(getActivity()).hasSession(account.getId())) {
        mi = menu.add(Menu.NONE, R.id.my_profile, Menu.FIRST, R.string.my_profile);
        mi.setIcon(R.drawable.ic_account_circle_grey);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
}

From source file:com.ushahidi.android.presentation.view.ui.activity.PostActivity.java

private void setNavigationViewMenuItems(@NonNull Menu menu) {
    // Reset menu items to avoid duplicates because we reinitialize them
    menu.clear();//from ww  w .  j a va 2  s.  com
    if (!Utility.isCollectionEmpty(mDeploymentModelList)) {
        SubMenu subMenu = menu.addSubMenu(Menu.NONE, Menu.FIRST, Menu.NONE, R.string.deployments);
        subMenu.setGroupCheckable(DEPLOYMENTS_MENU_ITEMS_GROUP_ID, true, true);
        // Use item position as the menu item's id that way we can retrieve the individual
        // deployment when user clicks on it to make it the active deployment
        for (int pos = 0; pos < mDeploymentModelList.size(); pos++) {
            subMenu.add(DEPLOYMENTS_MENU_ITEMS_GROUP_ID, pos, pos, mDeploymentModelList.get(pos).getTitle())
                    .setIcon(R.drawable.ic_action_globe);
            if (mDeploymentModelList.get(pos).getStatus().equals(DeploymentModel.Status.ACTIVATED)) {
                mNavigationView.getMenu().findItem(pos).setChecked(true);
                mToolbar.setTitle(mNavigationView.getMenu().findItem(pos).getTitle());
            } else {
                mNavigationView.getMenu().findItem(pos).setChecked(false);
            }
        }
    }

    mSubMenuMisc = menu.addSubMenu(Menu.NONE, Menu.FIRST, Menu.NONE, R.string.actions);

    mSubMenuMisc.add(MISC_MENU_ITEMS, MANAGE_DEPLOYMENT_MENU_ID, 1, R.string.manage_deployments)
            .setIcon(R.drawable.ic_action_map);

    mSubMenuMisc.add(MISC_MENU_ITEMS, FEEDBACK_MENU_ID, 2, R.string.send_feedback)
            .setIcon(R.drawable.ic_action_help);
    mSubMenuMisc.add(MISC_MENU_ITEMS, ABOUT_MENU_ID, 3, R.string.about).setIcon(R.drawable.ic_action_info);

    if (mSessionManager.getActiveSession() != null) {
        mSubMenuMisc.add(MISC_MENU_ITEMS, LOGOUT_MENU_ID, 4, R.string.logout)
                .setIcon(R.drawable.ic_action_logout);
    }

    mSubMenuMisc.setGroupCheckable(MISC_MENU_ITEMS, true, true);

}