Example usage for android.view MenuItem getIntent

List of usage examples for android.view MenuItem getIntent

Introduction

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

Prototype

public Intent getIntent();

Source Link

Document

Return the Intent associated with this item.

Usage

From source file:de.aw.monma.mainscreen.ActivityMainScreen.java

@Override
public boolean onMenuItemClick(MenuItem item) {
    Bundle extras = item.getIntent().getExtras();
    long id = extras.getLong(ID, NOID);
    switch (item.getItemId()) {
    case R.id.context_menu_item_deleteReport:
        DBDefinition reportTbd = DBDefinition.ReportBasisdaten;
        String selection = _id + " = " + id;
        DBHelper db = DBHelper.getInstance();
        db.delete(reportTbd, selection, null);
        return true;
    case R.id.context_menu_item_editReport:
        DialogReportDaten d = DialogReportDaten.newInstance(id);
        d.show(getSupportFragmentManager(), d.getTAG());
        return true;
    }/*from   w ww . jav a  2 s  .  co  m*/
    return false;
}

From source file:org.getlantern.firetweet.fragment.support.BaseUsersListFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    if (mSelectedUser == null)
        return false;
    switch (item.getItemId()) {
    default: {/*from  w ww  .j av a 2  s.c  o m*/
        if (item.getIntent() != null) {
            try {
                startActivity(item.getIntent());
            } catch (final ActivityNotFoundException e) {
                Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}

From source file:de.aw.monma.actions.FragmentWPList.java

@Override
public boolean onMenuItemClick(MenuItem item) {
    boolean consumed = false;
    AWFragment f = null;/*from w ww  . j  a  v a 2  s.c om*/
    Bundle extras = item.getIntent().getExtras();
    Long wpid = extras.getLong(WPID);
    String wpname = extras.getString(WPNAME);
    int mAccountID = extras.getInt(ACCOUNTID);
    switch (item.getItemId()) {
    case R.id.context_menu_item_wpKursAktualisieren:
        WPKurs kurs = new WPKurs();
        kurs.put(column_wpid, wpid);
        kurs.setWPName(wpname);
        DialogKursaktualisierung dialog = DialogKursaktualisierung.newInstance(kurs);
        dialog.show(getFragmentManager(), dialog.TAG);
        consumed = true;
        break;
    case R.id.context_menu_item_wpPaketeansehen:
        f = FragmentWPPaketListe.newInstance(mAccountID, wpid, new Bundle());
        wpname = extras.getString(WPNAME);
        setTitle(getString(R.string.Pakete) + " " + wpname);
        f.setArguments(extras);
        consumed = true;
        break;
    case R.id.context_menu_item_wpKurseBearbeiten:
        f = new FragmentWertpapierKurseListe();
        f.setArguments(extras);
        setTitle(R.string.tvKursFuerWertpapier);
        consumed = true;
        break;
    case R.id.context_menu_item_wpUmsaetze:
        f = FragmentWertpapierBuchungenListe.newInstance(mAccountID, wpid, wpname);
        consumed = true;
        break;
    case R.id.context_menu_item_wpErtraegeDetails:
        Intent intent = item.getIntent();
        intent.setClass(getActivity(), ActivityActions.class);
        intent.putExtra(ACTION, (Parcelable) Action.ShowWPDetails);
        startActivity(intent);
        consumed = true;
        break;
    default:
    }
    if (f != null) {
        replaceFragment(f);
    }
    return consumed;
}

From source file:de.vanita5.twittnuker.fragment.support.BaseUsersListFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    if (mSelectedUser == null)
        return false;
    switch (item.getItemId()) {
    default: {/*from   w w w  .  ja  va  2s .  c om*/
        if (item.getIntent() != null) {
            try {
                startActivity(item.getIntent());
            } catch (final ActivityNotFoundException e) {
                if (Utils.isDebugBuild())
                    Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}

From source file:org.getlantern.firetweet.fragment.CustomTabsFragment.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    default: {/*from  ww  w . j a  va 2  s.co m*/
        final Intent intent = item.getIntent();
        if (intent == null)
            return false;
        startActivityForResult(intent, REQUEST_ADD_TAB);
        return true;
    }
    }
}

From source file:org.mariotaku.twidere.fragment.UserListMembersFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    if (mSelectedUser == null)
        return false;
    switch (item.getItemId()) {
    case MENU_DELETE: {
        mTwitterWrapper.deleteUserListMember(getAccountId(), mUserListId, mSelectedUser.user_id);
        break;/*  w w w. j  a v  a 2s .  c om*/
    }
    case MENU_VIEW_PROFILE: {
        openUserProfile(getActivity(), mSelectedUser);
        break;
    }
    default: {
        if (item.getIntent() != null) {
            try {
                startActivity(item.getIntent());
            } catch (final ActivityNotFoundException e) {
                Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return false;
}

From source file:org.mariotaku.twidere.fragment.BaseUserListsListFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    if (mSelectedUserList == null)
        return false;
    switch (item.getItemId()) {
    case MENU_VIEW_USER_LIST: {
        openUserListDetails(getActivity(), mAccountId, mSelectedUserList.list_id, mSelectedUserList.user_id,
                mSelectedUserList.user_screen_name, mSelectedUserList.name);
        break;//from   w  w w .j  a v  a2s  . c o  m
    }
    default: {
        if (item.getIntent() != null) {
            try {
                startActivity(item.getIntent());
            } catch (final ActivityNotFoundException e) {
                Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}

From source file:com.android.deskclock.DeskClock.java

private void showMenu(View v) {
    PopupMenu popupMenu = new PopupMenu(this, v);
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override//from   w  w w . j a  va2 s .  c  om
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.menu_item_settings:
                startActivity(new Intent(DeskClock.this, SettingsActivity.class));
                return true;
            case R.id.menu_item_help:
                Intent i = item.getIntent();
                if (i != null) {
                    try {
                        startActivity(i);
                    } catch (ActivityNotFoundException e) {
                        // No activity found to match the intent - ignore
                    }
                }
                return true;
            case R.id.menu_item_night_mode:
                startActivity(new Intent(DeskClock.this, ScreensaverActivity.class));
            default:
                break;
            }
            return true;
        }
    });
    popupMenu.inflate(R.menu.desk_clock_menu);

    Menu menu = popupMenu.getMenu();
    MenuItem help = menu.findItem(R.id.menu_item_help);
    if (help != null) {
        Utils.prepareHelpMenuItem(this, help);
    }
    popupMenu.show();
}

From source file:org.getlantern.firetweet.fragment.support.BaseUserListsListFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    if (mSelectedUserList == null)
        return false;
    switch (item.getItemId()) {
    case MENU_ADD: {
        AddUserListMemberDialogFragment.show(getFragmentManager(), mSelectedUserList.account_id,
                mSelectedUserList.id);/*w  ww . j a  v  a2s .  c  o  m*/
        break;
    }
    case MENU_DELETE: {
        mTwitterWrapper.destroyUserListAsync(mSelectedUserList.account_id, mSelectedUserList.id);
        break;
    }
    default: {
        if (item.getIntent() != null) {
            try {
                startActivity(item.getIntent());
            } catch (final ActivityNotFoundException e) {
                Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}

From source file:de.vanita5.twittnuker.fragment.support.BaseUserListsListFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    if (mSelectedUserList == null)
        return false;
    switch (item.getItemId()) {
    case MENU_ADD: {
        AddUserListMemberDialogFragment.show(getFragmentManager(), mSelectedUserList.account_id,
                mSelectedUserList.id);//from ww w  . java2s .  c  om
        break;
    }
    case MENU_DELETE: {
        mTwitterWrapper.destroyUserListAsync(mSelectedUserList.account_id, mSelectedUserList.id);
        break;
    }
    default: {
        if (item.getIntent() != null) {
            try {
                startActivity(item.getIntent());
            } catch (final ActivityNotFoundException e) {
                if (Utils.isDebugBuild())
                    Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}