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

The following are Jave code examples for showing how to use getOrder() 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: robird-reborn   File: HomeActivity.java   View Source Code Vote up 6 votes
@Override
public boolean onNavigationItemSelected(final MenuItem menuItem) {
    if (menuItem.getItemId() != R.id.navigation_item_settings) {
        if (mSelectedNavigationPosition != menuItem.getOrder() ||
                mSelectedAccountId != mAccounts.get(0).id()) {
            mPager.post(new Runnable() {
                @Override
                public void run() {
                    mPager.setCurrentItem(menuItem.getOrder(), false);
                }
            });
        }

        selectNavigation(menuItem);
    } else {
        ActivityCompat.startActivity(this, new Intent(this, SettingsActivity.class), null);
    }

    return true;
}
 
Example 2
Project: EasyTodo   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
public boolean onContextItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    int clickedItemPosition = item.getOrder();
    TodoEvent event = eventList.get(clickedItemPosition);
    switch (item.getItemId()) {
        case 1:
            event.delete();
            eventList.remove(clickedItemPosition);
            MyAdapter.notifyItemRangeRemoved(clickedItemPosition, 1);
            MyAdapter.setTodoEventSize(MyAdapter.getTodoEventSize()-1);
            Snackbar.make(MyAdapter.getHolder().itemView,"你删掉了这条项目",Snackbar.LENGTH_SHORT).show();
            showNoEvent();
            break;
        default:
            break;
    }
    return super.onContextItemSelected(item);
}
 
Example 3
Project: MBEStyle   File: MainActivity.java   View Source Code Vote up 5 votes
@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
Project: android-apps   File: TodoFragment.java   View Source Code Vote up 5 votes
@Override
public boolean onMenuItemClick(MenuItem item) {
  switch (item.getOrder()) {
    case 0:
      Intent intent = new Intent(getActivity(), WeatherActivity.class);
      startActivity(intent);
      return true;
    case 1:
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      View alertDialogView = LayoutInflater.from(getActivity()).inflate(R.layout.alert_add_todo, null);
      builder.setView(alertDialogView);
      final EditText contentEt = (EditText) alertDialogView.findViewById(R.id.contentEt);
      builder.setMessage(R.string.please_type);
      builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
          String todoContent = contentEt.getText().toString();
          if (todoContent.length() > 0) {
            localTodoData.add(todoContent);
            SharedPreferencesUtil.saveLocalTodos(localTodoData, getActivity());
            contentEt.setText("");
            fetchData();
          }
        }
      });
      builder.setNegativeButton(android.R.string.cancel, null);
      builder.create().show();
      return true;
    default:
      return false;
  }
}
 
Example 5
Project: robird-reborn   File: HomeActivity.java   View Source Code Vote up 5 votes
public void selectNavigation(MenuItem menuItem) {
    mSelectedAccountId = mAccounts.get(0).id();
    mSelectedNavigationPosition = menuItem.getOrder();
    setTitle(menuItem.getTitle());
    menuItem.setChecked(true);
    mDrawerLayout.closeDrawers();
}
 
Example 6
Project: MaterialFabSpeedDial   File: FabSpeedDialMenu.java   View Source Code Vote up 4 votes
@Override
public int compare(MenuItem o1, MenuItem o2) {
    return o1.getOrder() - o2.getOrder();
}