Java Code Examples for android.view.MenuItem.getGroupId()

The following are Jave code examples for showing how to use getGroupId() of the android.view.MenuItem class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: MediaVariationsFragment.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  if (item.getItemId() == R.id.media_variations_clear_cache) {
    Fresco.getImagePipeline().clearCaches();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      getActivity().recreate();
    } else {
      Toast.makeText(
          getActivity(),
          R.string.imagepipeline_media_variations_restart_toast,
          Toast.LENGTH_SHORT).show();
      getActivity().finish();
    }
    return true;
  } else if (item.getGroupId() == R.id.media_variations_modes) {
    for (Mode mode : Mode.values()) {
      if (mode.menuItemId == item.getItemId()) {
        setMode(mode);
        break;
      }
    }
    clearMainImageAndBitmapCache();
    item.setChecked(true);
  }

  return super.onOptionsItemSelected(item);
}
 
Example 2
Project: CCDownload   File: DownloadingFragment.java   View Source Code Vote up 5 votes
public boolean onContextItemSelected(MenuItem item) {
	if (item.getGroupId() != ConfigUtil.DOWNLOADING_MENU_GROUP_ID) {
		return false;
	}
	
	int selectedPosition = ((AdapterContextMenuInfo) item.getMenuInfo()).position;// 获取点击了第几行
	DownloadInfo downloadInfo = (DownloadInfo) downloadAdapter.getItem(selectedPosition);
	String title = downloadInfo.getTitle();

	// 删除数据库记录
	DataSet.removeDownloadInfo(title);

	File file = new File(Environment.getExternalStorageDirectory()+"/CCDownload", title+".mp4");
	if(file.exists()){
		file.delete();
	}
	
	// 通知service取消下载
	if (!binder.isStop() && binder.exists(title)) {
		binder.cancel(title);
		startWaitStatusDownload();
	}
	
	initData();
	downloadAdapter.notifyDataSetChanged();
	downloadingListView.invalidate();

	if (getUserVisibleHint()) {
		return true;
	}
	
	return false;
}
 
Example 3
Project: CCDownload   File: DownloadedFragment.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
@Override
public boolean onContextItemSelected(MenuItem item) {
	if (item.getGroupId() != ConfigUtil.DOWNLOADED_MENU_GROUP_ID) {
		return false;
	}
	
	int selectedPosition = ((AdapterContextMenuInfo) item.getMenuInfo()).position;
	
	Pair<String, Integer> pair = (Pair<String, Integer>)videoListViewAdapter.getItem(selectedPosition);
	
	DataSet.removeDownloadInfo(pair.first);
	
	File file = new File(Environment.getExternalStorageDirectory()+"/"+ConfigUtil.DOWNLOAD_DIR, pair.first+".mp4");
	if(file.exists()){
		file.delete();
	}
	
	initData();
	videoListViewAdapter.notifyDataSetChanged();
	downloadedListView.invalidate();

	if (getUserVisibleHint()) {
		return true;
	}

	return false;
}
 
Example 4
Project: MyCalendar   File: AddEditDetailSubjectActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onContextItemSelected(MenuItem item) {
    int id_group = item.getGroupId();

    switch (id_group) {
        case ID_GROUP_TEACHER:
            String name = item.getTitle().toString();
            mView_TeacherName.setText(name);
            break;
    }
    return super.onContextItemSelected(item);
}
 
Example 5
Project: MyCalendar   File: WeekLessonDetailActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onContextItemSelected(MenuItem item) {
    int id_group = item.getGroupId();

    switch (id_group) {
        case ID_GROUP_SUBJECT:
            changeSubject(item.getItemId());
            break;
    }
    return super.onContextItemSelected(item);
}
 
Example 6
Project: orgzly-android   File: SearchFragment.java   View Source Code Vote up 5 votes
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, actionMode, menuItem);

    switch (menuItem.getItemId()) {
        case R.id.query_cab_schedule:
            displayScheduleTimestampDialog(R.id.query_cab_schedule, mSelection.getIds());
            break;

        case R.id.query_cab_state:
            /* Add all known states to menu. */
            SubMenu subMenu = menuItem.getSubMenu();
            if (subMenu != null) {
                subMenu.clear();
                for (String str: new NoteStateSpinner(getActivity(), null).getValues()) {
                    subMenu.add(STATE_ITEM_GROUP, Menu.NONE, Menu.NONE, str);
                }
            }
            break;

        default:
            /* Click on one of the state keywords. */
            if (menuItem.getGroupId() == STATE_ITEM_GROUP) {
                if (mListener != null) {
                    mListener.onStateChangeRequest(mSelection.getIds(), menuItem.getTitle().toString());
                }
                return true;
            }

            return false; // Not handled.
    }

    return true; // Handled.
}
 
Example 7
Project: orgzly-android   File: AgendaFragment.java   View Source Code Vote up 5 votes
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, actionMode, menuItem);
    TreeSet<Long> selectionIds;
    switch (menuItem.getItemId()) {
        case R.id.query_cab_schedule:
            selectionIds = originalSelectedIds();
            if (!selectionIds.isEmpty()) {
                displayScheduleTimestampDialog(R.id.query_cab_schedule, selectionIds);
            }
            break;

        case R.id.query_cab_state:
            /* Add all known states to menu. */
            SubMenu subMenu = menuItem.getSubMenu();
            if (subMenu != null) {
                subMenu.clear();
                for (String str: new NoteStateSpinner(getActivity(), null).getValues()) {
                    subMenu.add(STATE_ITEM_GROUP, Menu.NONE, Menu.NONE, str);
                }
            }
            break;

        default:
            /* Click on one of the state keywords. */
            if (menuItem.getGroupId() == STATE_ITEM_GROUP) {
                if (mListener != null) {
                    selectionIds = originalSelectedIds();
                    if (!selectionIds.isEmpty()) {
                        mListener.onStateChangeRequest(selectionIds, menuItem.getTitle().toString());
                    }
                }
                return true;
            }

            return false; // Not handled.
    }

    return true; // Handled.
}
 
Example 8
Project: boohee_v5.6   File: MenuBuilder.java   View Source Code Vote up 5 votes
void setExclusiveItemChecked(MenuItem item) {
    int group = item.getGroupId();
    int N = this.mItems.size();
    for (int i = 0; i < N; i++) {
        MenuItem curItem = (MenuItemImpl) this.mItems.get(i);
        if (curItem.getGroupId() == group && curItem.isExclusiveCheckable() && curItem.isCheckable()) {
            curItem.setCheckedInt(curItem == item);
        }
    }
}
 
Example 9
Project: SocEltech   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onContextItemSelected(MenuItem item) {
	switch (item.getGroupId()) {
		case R.id.delete:
			deleteItem(item.getItemId());
			return true;
		case R.id.edit:
			Intent i = new Intent(MainActivity.this, AddTestActivity.class);
			i.putExtra(AddTestActivity.ARG_TEST_ID, socTests.get(item.getItemId()).getId());
			startActivity(i);
			return true;
		default:
			return super.onContextItemSelected(item);
	}
}
 
Example 10
Project: Todule-android   File: MainActivity.java   View Source Code Vote up 4 votes
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    int loaderId = 0;
    switch(item.getGroupId()){
        case R.id.navgroup_list:
            switch(item.getItemId()){
                case R.id.nav_incomplete:
                    loaderId = 1;
                    break;
                case R.id.nav_expired:
                    loaderId = 2;
                    break;
                case R.id.nav_completed:
                    loaderId = 3;
                    break;
                case R.id.nav_archive:
                    loaderId = 4;
                    break;
                case R.id.nav_deleted:
                    loaderId = 5;
                    break;
            }
            navigationView.setCheckedItem(item.getItemId());
            ToduleListFragment frag = ToduleListFragment.newInstance(loaderId);
            getSupportFragmentManager().beginTransaction()
                    .setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
                    .replace(R.id.fragment_container, frag, "list_frag" + String.valueOf(loaderId))
                    .commit();
            mDrawerLayout.closeDrawer(GravityCompat.START);
            return true;
        case R.id.navgroup_setting:
            switch(item.getItemId()){
                case R.id.nav_label:
                    navigationView.setCheckedItem(item.getItemId());
                    ToduleLabelFragment labelFrag = ToduleLabelFragment.newInstance(false, null);
                    getSupportFragmentManager().beginTransaction()
                            .setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
                            .replace(R.id.fragment_container, labelFrag)
                            .commit();
                    mDrawerLayout.closeDrawer(GravityCompat.START);
                    break;
            }
            return true;
    }
    return true;
}
 
Example 11
Project: XPrivacy   File: ActivityApp.java   View Source Code Vote up 4 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
	case android.R.id.home:
		Intent upIntent = NavUtils.getParentActivityIntent(this);
		if (upIntent != null)
			if (NavUtils.shouldUpRecreateTask(this, upIntent))
				TaskStackBuilder.create(this).addNextIntentWithParentStack(upIntent).startActivities();
			else
				NavUtils.navigateUpTo(this, upIntent);
		return true;
	case R.id.menu_usage:
		optionUsage();
		return true;
	case R.id.menu_accounts:
		optionAccounts();
		return true;
	case R.id.menu_applications:
		optionApplications();
		return true;
	case R.id.menu_contacts:
		if (item.getGroupId() != 0) {
			optionContacts(item.getGroupId());
			return true;
		} else
			return false;
	case R.id.menu_whitelists:
		optionWhitelists(null);
		return true;
	case R.id.menu_apply:
		optionTemplate();
		return true;
	case R.id.menu_clear:
		optionClear();
		return true;
	case R.id.menu_export:
		optionExport();
		return true;
	case R.id.menu_import:
		optionImport();
		return true;
	case R.id.menu_submit:
		optionSubmit();
		return true;
	case R.id.menu_fetch:
		optionFetch();
		return true;
	case R.id.menu_settings:
		optionSettings();
		return true;
	case R.id.menu_dump:
		optionDump();
		return true;
	case R.id.menu_legend:
		optionLegend();
		return true;
	case R.id.menu_tutorial:
		optionTutorial();
		return true;
	default:
		return super.onOptionsItemSelected(item);
	}
}