Example usage for android.view MenuItem getMenuInfo

List of usage examples for android.view MenuItem getMenuInfo

Introduction

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

Prototype

public ContextMenuInfo getMenuInfo();

Source Link

Document

Gets the extra information linked to this menu item.

Usage

From source file:ca.cs.ualberta.localpost.view.FreshestTabView.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    ConnectivityCheck conn = new ConnectivityCheck(getActivity());

    // Get item list index
    ElasticSearchOperations es = new ElasticSearchOperations();
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    int index = (int) info.id;
    switch (item.getItemId()) {

    case Menu.FIRST://UpRad
        if (conn.isConnectingToInternet()) {
            Toast.makeText(getActivity(), "UpRad", Toast.LENGTH_SHORT).show();
            model.get(index).incRadish();
            es.execute(1, model.get(index).getPostId(), model.get(index), null);
            return true;
        } else {/*from  w w  w.  j a v a 2  s .  c  o  m*/
            Toast.makeText(getActivity(), "You require connectivity to Uprad", Toast.LENGTH_SHORT).show();
            return true;
        }
    case Menu.FIRST + 1://Down rad
        if (conn.isConnectingToInternet()) {
            Toast.makeText(getActivity(), "DownRad", Toast.LENGTH_SHORT).show();
            model.get(index).decRadish();
            es.execute(1, model.get(index).getPostId(), model.get(index), null);
            return true;
        } else {
            Toast.makeText(getActivity(), "You require connectivity to Downrad", Toast.LENGTH_SHORT).show();
            return true;
        }
    case Menu.FIRST + 2://Favorites
        Serialize.SaveComment(model.get(index), getActivity(), "favourite");
        Toast.makeText(getActivity(), "Comment has been Favorited", Toast.LENGTH_SHORT).show();
        Serialize.update(model.get(index), getActivity(), "favoritecomment.json");
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:ca.cs.ualberta.localpost.view.NoPicTabView.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    ConnectivityCheck conn = new ConnectivityCheck(getActivity());

    // Get item list index
    ElasticSearchOperations es = new ElasticSearchOperations();
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    int index = (int) info.id;
    switch (item.getItemId()) {
    case Menu.FIRST:
        if (conn.isConnectingToInternet()) {
            Toast.makeText(getActivity(), "UpRad", Toast.LENGTH_SHORT).show();
            model.get(index).incRadish();
            es.execute(1, model.get(index).getPostId(), model.get(index), null);
            return true;
        } else {/* w w w . j av a  2  s  . co  m*/
            Toast.makeText(getActivity(), "You require connectivity to Uprad", Toast.LENGTH_SHORT).show();
            return true;
        }
    case Menu.FIRST + 1:
        if (conn.isConnectingToInternet()) {
            Toast.makeText(getActivity(), "DownRad", Toast.LENGTH_SHORT).show();
            model.get(index).decRadish();
            es.execute(1, model.get(index).getPostId(), model.get(index), null);
            return true;
        } else {
            Toast.makeText(getActivity(), "You require connectivity to Downrad", Toast.LENGTH_SHORT).show();
            return true;
        }

    case Menu.FIRST + 2:
        Serialize.SaveComment(model.get(index), getActivity(), "favourite");
        Toast.makeText(getActivity(), "Comment has been Favorited", Toast.LENGTH_SHORT).show();
        Serialize.update(model.get(index), getActivity(), "favoritecomment.json");
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:com.ysls.imhere.fragment.ChatHistoryFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.delete_message) {
        EMContact tobeDeleteUser = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
        // ?//from   w ww  . j a  v  a 2s.com
        EMChatManager.getInstance().deleteConversation(tobeDeleteUser.getUsername());
        InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity());
        inviteMessgeDao.deleteMessage(tobeDeleteUser.getUsername());
        adapter.remove(tobeDeleteUser);
        adapter.notifyDataSetChanged();

        // ?
        // ((MainActivity) getActivity()).updateUnreadLabel();

        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:com.markupartist.sthlmtraveling.FavoritesFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case CONTEXT_MENU_DELETE:
        getActivity().getContentResolver().delete(ContentUris.withAppendedId(Journeys.CONTENT_URI, menuInfo.id),
                null, null);/* w  w  w.ja v  a  2s. c om*/
        return true;
    case CONTEXT_MENU_REVERSE_SEARCH:
        doSearch(menuInfo.id, true);
        return true;
    case CONTEXT_MENU_INCREASE_PRIO:
        updateListPosition(menuInfo.id, true);
        return true;
    case CONTEXT_MENU_DECREASE_PRIO:
        updateListPosition(menuInfo.id, false);
        return true;
    }
    return false;
}

From source file:net.tacks_a.ankicard.fragment.AnkiFolderListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    LogUtil.logDebug();//from w w  w .  j a v  a 2  s  .  c  om
    AdapterView.AdapterContextMenuInfo info;
    info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    switch (item.getItemId()) {
    case R.id.lst_anki_folder_edit:
        // 
        showEditFolder(mAnkiFolderList.get(info.position));
        return true;
    case R.id.lst_anki_folder_delete:
        // 
        deleteFolder(mAnkiFolderList.get(info.position));
        return true;
    case R.id.lst_anki_folder_show_anki_card_list:
        // 
        showAnkiCardList(mAnkiFolderList.get(info.position));
        return true;
    case R.id.lst_anki_folder_show_exam:
        // ?
        showQuestionCondition(mAnkiFolderList.get(info.position));
        return true;
    }
    return false;
}

From source file:net.zionsoft.obadiah.ui.fragments.TranslationListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo contextMenuInfo = (AdapterView.AdapterContextMenuInfo) item
            .getMenuInfo();/*  ww  w . jav a  2  s .com*/
    if (contextMenuInfo == null)
        return super.onContextItemSelected(item);

    final TranslationInfo translationInfo = getTranslationInfo(contextMenuInfo);
    if (translationInfo == null) {
        return super.onContextItemSelected(item);
    }

    switch (item.getItemId()) {
    case CONTEXT_MENU_ITEM_DELETE:
        DialogHelper.showDialog(getActivity(), true, R.string.dialog_translation_delete_confirm_message,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        removeTranslation(translationInfo.shortName);
                    }
                }, null);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:cn.ucai.yizhesale.activity.ChatHistoryFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == cn.ucai.yizhesale.R.id.delete_message) {
        EMContact tobeDeleteUser = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
        boolean isGroup = false;
        if (tobeDeleteUser instanceof EMGroup)
            isGroup = true;/*from   w  ww. j av  a  2s  .c o  m*/
        // ?
        EMChatManager.getInstance().deleteConversation(tobeDeleteUser.getUsername(), isGroup);
        InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity());
        inviteMessgeDao.deleteMessage(tobeDeleteUser.getUsername());
        adapter.remove(tobeDeleteUser);
        adapter.notifyDataSetChanged();

        // ?
        ((MainActivity) getActivity()).updateUnreadLabel();

        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:org.kochka.android.weightlogger.WeightLoggerActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo menuInfo;
    menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    final Measurement measurement = (Measurement) mList.getItemAtPosition(menuInfo.position);
    switch (item.getItemId()) {
    case 0:/*  ww w .j a  v  a 2  s .c o  m*/
        Intent i = new Intent(this, EditMeasurementActivity.class);
        i.putExtra("id", measurement.getId());
        startActivityForResult(i, 0);
        break;
    case 1:
        new AlertDialog.Builder(this).setTitle(R.string.confirm_delete)
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        measurement.destroy();
                        ((MeasurementsListAdapter) mList.getAdapter()).refresh();
                        Toast.makeText(WeightLoggerActivity.this, R.string.record_deleted, Toast.LENGTH_SHORT)
                                .show();
                    }
                }).setNegativeButton(android.R.string.no, null).show();
        break;
    }
    return true;
}

From source file:org.gateshipone.odyssey.fragments.AlbumTracksFragment.java

/**
 * Hook called when an menu item in the context menu is selected.
 *
 * @param item The menu item that was selected.
 * @return True if the hook was consumed here.
 *//*from   w  ww.  jav a 2s . com*/
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    if (info == null) {
        return super.onContextItemSelected(item);
    }

    switch (item.getItemId()) {
    case R.id.fragment_album_tracks_action_enqueue:
        enqueueTrack(info.position, false);
        return true;
    case R.id.fragment_album_tracks_action_enqueueasnext:
        enqueueTrack(info.position, true);
        return true;
    case R.id.fragment_album_tracks_action_showartist:
        showArtist(info.position);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.dgsd.android.ShiftTracker.Fragment.WeekFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    final View view = (ViewGroup) info.targetView.findViewById(R.id.new_shift).getParent();
    final WeekAdapter.ViewHolder holder = (WeekAdapter.ViewHolder) view.getTag();

    final Intent intent = getIntentFor(holder);
    if (item.getItemId() == R.id.template_shift) {
        showTemplateChooser(holder.julianDay);
    } else if (item.getItemId() == R.id.new_shift) {
        startActivity(intent);//  w w  w  .j a  v  a 2 s .  c om
    } else if (item.getItemId() == R.id.delete) {
        if (holder.shift.isTemplate) {
            /**
             * We dont want to delete templates, just remove them from view. Do this by giving them bogus dates
             */
            final ContentValues values = new ContentValues();
            values.put(DbField.JULIAN_DAY.name, -1);
            values.put(DbField.END_JULIAN_DAY.name, -1);

            DbService.async_update(getActivity(), Provider.SHIFTS_URI,
                    DbField.ID + "=" + (holder.shift == null ? -1 : holder.shift.id), values);
        } else {
            DbService.async_delete(getActivity(), Provider.SHIFTS_URI,
                    DbField.ID + "=" + (holder.shift == null ? -1 : holder.shift.id));
        }

        AlarmUtils.get(getActivity()).cancel(holder.shift);
        showMessage("Shift deleted");
    }

    return true;
}