public void onClick(View v) {
   // Validate mPosition
   if (mPosition >= 0 && mPosition < mSlideshowModel.size()) {
     mSlideshowEditor.removeSlide(mPosition);
     int size = mSlideshowModel.size();
     if (size > 0) {
       if (mPosition >= size) {
         mPosition--;
       }
       showCurrentSlide();
     } else {
       finish();
       return;
     }
   }
 }
Пример #2
0
  @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;
  }