private void addNewSlide() {
    if (mSlideshowEditor.addNewSlide()) {
      // add successfully
      mSlideListAdapter.notifyDataSetChanged();

      // Select the new slide.
      mList.requestFocus();
      mList.setSelection(mSlideshowModel.size() - 1);
    } else {
      Toast.makeText(this, R.string.cannot_add_slide_anymore, Toast.LENGTH_SHORT).show();
    }
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int position = mList.getSelectedItemPosition();

    switch (item.getItemId()) {
      case MENU_MOVE_UP:
        if ((position > 0) && (position < mSlideshowModel.size())) {
          mSlideshowEditor.moveSlideUp(position);
          mSlideListAdapter.notifyDataSetChanged();
          mList.setSelection(position - 1);
        }
        break;
      case MENU_MOVE_DOWN:
        if ((position >= 0) && (position < mSlideshowModel.size() - 1)) {
          mSlideshowEditor.moveSlideDown(position);
          mSlideListAdapter.notifyDataSetChanged();
          mList.setSelection(position + 1);
        }
        break;
      case MENU_REMOVE_SLIDE:
        if ((position >= 0) && (position < mSlideshowModel.size())) {
          mSlideshowEditor.removeSlide(position);
          mSlideListAdapter.notifyDataSetChanged();
        }
        break;
      case MENU_ADD_SLIDE:
        addNewSlide();
        break;
      case MENU_DISCARD_SLIDESHOW:
        // delete all slides from slideshow.
        mSlideshowEditor.removeAllSlides();
        mSlideListAdapter.notifyDataSetChanged();
        finish();
        break;
    }

    return true;
  }