Java Code Examples for android.view.MenuItem#getOrder()

The following examples show how to use android.view.MenuItem#getOrder() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
    super.onOptionsItemSelected(item);
    switch (item.getOrder())
    {
        case MENU_POST:
            Log.d(TAG, "onOptionsItemSelected: ");
            if (!LoginUtils.isLoggedIn()){
                showToast(R.string.please_login);
                break;
            }
            viewModel.postConversation();
            break;
        case MENU_DEMO:
            viewModel.changeDemoMode();
            break;
    }
    return true;
}
 
Example 2
Source Project: pandora   File: SPFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getMenuInfo() instanceof MenuRecyclerView.RvContextMenuInfo) {
        MenuRecyclerView.RvContextMenuInfo info = (MenuRecyclerView.RvContextMenuInfo) item.getMenuInfo();
        BaseItem baseItem = getAdapter().getItems().get(info.position);

        if (baseItem instanceof KeyValueItem) {
            KeyValueItem keyValueItem = (KeyValueItem) baseItem;

            if (keyValueItem.isTitle) {
                return true;
            }

            if (item.getOrder() == 0) {
                Utils.copy2ClipBoard(
                        "KEY :: " + keyValueItem.data[0] + "\nVALUE  :: " + keyValueItem.data[1]
                );
                return true;
            } else if (item.getOrder() == 1) {
                String clickedKey = keyValueItem.data[0];
                Pandora.get().getSharedPref().removeSharedPrefKey(descriptor, clickedKey);
                getAdapter().removeItem(info.position);
                return true;
            }
        }
    }
    return super.onContextItemSelected(item);
}
 
Example 3
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    int order = item.getOrder();

    if (order >= 0 && order <= 3) {
        handleToolbarElevation(order);
        switchFragment(order);
        return true;
    }

    return false;
}
 
Example 4
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);
    switch (item.getOrder()){
        case MENU_SETTING:
            //startActivity(new Intent(HomepageActivity.this, SettingsActivity.class));
            startActivityForResult(new Intent(HomepageActivity.this, SettingsActivity.class), SETTING_CODE);
            break;
        case MENU_LOGOUT:
            // showProcessDialog(getString(R.string.just_a_sec));
            Toast.makeText(getApplicationContext(), R.string.logout_success, Toast.LENGTH_SHORT).show();
            Intent intent = new Intent(HomepageActivity.this, MainActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            LoginUtils.logout(new LoginUtils.LogoutObserver() {
                @Override
                public void onLogoutSuccess() {
                    // dismissProcessDialog();
                }

                @Override
                public void onLogoutFailure(int statusCode) {
                    dismissProcessDialog();
                    showToast(R.string.network_err);
                }
            });

            break;
    }
    return true;
}
 
Example 5
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
	super.onOptionsItemSelected(item);
	switch (item.getOrder())
	{
		case MENU_REPLY:
			switch (viewModel.flag.get())
			{
				case FLAG_NORMAL:
					if (!LoginUtils.isLoggedIn()){
						showToast(R.string.please_login);
						break;
					}
					viewModel.reply();
					break;
				case FLAG_EDIT:
					viewModel.edit();
					break;
			}
			break;
		case MENU_DEMO:
			viewModel.changeDemoMode();
			break;
	}
	return true;
}
 
Example 6
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
	super.onOptionsItemSelected(item);
	switch (item.getOrder())
	{
		case menu_settings:
			CharSequence[] settingsMenu = {getString(R.string.ignore_this), getString(R.string.mark_as_unread)};
			AlertDialog.Builder ab = new AlertDialog.Builder(this)
					.setTitle(R.string.settings)
					.setCancelable(true)
					.setItems(settingsMenu, new DialogInterface.OnClickListener()
					{
						@Override
						public void onClick(DialogInterface dialog, int which)
						{
							switch (which)
							{
								case 0:
									ConversationUtils.ignoreConversation(mContext, viewModel.conversationId, (PostActivity) mContext);
									break;
								case 1:
									showToast(R.string.mark_as_unread);
									break;
							}
						}
					});
			ab.show();
			break;
		case menu_reverse:
			if (viewModel.isReversed()) {
				item.setTitle(R.string.descend);
			} else {
				item.setTitle(R.string.ascend);
			}
			viewModel.reverseBtnClick();
			break;
		case menu_share:
			share();
			break;
		case menu_author_only:
			/*finish();
			Intent author_only = new Intent(this, PostActivity.class);
			author_only.putExtra("conversationId", viewModel.conversationId);
			author_only.putExtra("page", viewModel.isAuthorOnly ? "" : "?author=lz");
			author_only.putExtra("title", viewModel.title);
			author_only.putExtra("isAuthorOnly", !isAuthorOnly);
			startActivity(author_only);*/
			break;
		case menu_star:
			// TODO: 16-3-28 2201 Star light
			if (!LoginUtils.isLoggedIn()){
                   showToast(R.string.please_login);
                   break;
               }
			ConversationUtils.starConversation(this, viewModel.conversationId, this);
			break;
	}

	return true;
}
 
Example 7
Source Project: react-native-navigation   File: TitleBar.java    License: MIT License 4 votes vote down vote up
public boolean containsRightButton(@Nullable MenuItem menuItem, int order) {
    return menuItem != null &&
           getMenu().findItem(menuItem.getItemId()) != null &&
           menuItem.getOrder() == order;
}
 
Example 8
Source Project: fogger   File: StubMenuItemData.java    License: Apache License 2.0 4 votes vote down vote up
public static StubMenuItemData create(MenuItem menuItem) {
    return new StubMenuItemData(menuItem.getGroupId(),
            menuItem.getItemId(), menuItem.getOrder(), menuItem.getTitle().toString());
}
 
Example 9
Source Project: GestureViews   File: SettingsMenu.java    License: Apache License 2.0 4 votes vote down vote up
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.string.menu_enable_pan:
            isPanEnabled = !isPanEnabled;
            break;
        case R.string.menu_enable_zoom:
            isZoomEnabled = !isZoomEnabled;
            break;
        case R.string.menu_enable_rotation:
            isRotationEnabled = !isRotationEnabled;
            break;
        case R.string.menu_restrict_rotation:
            isRestrictRotation = !isRestrictRotation;
            break;
        case R.string.menu_enable_overscroll:
            isOverscrollEnabled = !isOverscrollEnabled;
            break;
        case R.string.menu_enable_overzoom:
            isOverzoomEnabled = !isOverzoomEnabled;
            break;
        case R.string.menu_fill_viewport:
            isFillViewport = !isFillViewport;
            break;
        case R.string.menu_fit_method:
            fitMethod = Settings.Fit.values()[item.getOrder()];
            break;
        case R.string.menu_bounds_type:
            boundsType = Settings.Bounds.values()[item.getOrder()];
            break;
        case R.string.menu_gravity:
            gravity = GravityType.values()[item.getOrder()].gravity;
            break;
        case R.string.menu_enable_slow:
            isSlow = !isSlow;
            break;
        case R.string.menu_enable_overlay:
            GestureDebug.setDrawDebugOverlay(!GestureDebug.isDrawDebugOverlay());
            break;
        default:
            return false;
    }

    return true;
}