예제 #1
0
 public boolean onContextItemSelected(MenuItem item) {
   AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
   switch (item.getItemId()) {
     case ADD_STEP:
       selectedStep = preset.blankStep();
       preset.steps.add(info.position + 1, selectedStep);
       modifiedStep = selectedStep.clone();
       showDialog(EDIT_STEP);
       return true;
     case DUP_STEP:
       selectedStep = preset.steps.get(info.position).clone();
       selectedStep.name = selectedStep.name + " copy";
       preset.steps.add(info.position + 1, selectedStep);
       modifiedStep = selectedStep.clone();
       showDialog(EDIT_STEP);
       return true;
     case UP_STEP:
       Collections.swap(preset.steps, info.position, info.position - 1);
       adapter.notifyDataSetChanged();
       return true;
     case DOWN_STEP:
       Collections.swap(preset.steps, info.position, info.position + 1);
       adapter.notifyDataSetChanged();
       return true;
     case DEL_STEP: // Unreachable right now.
       preset.steps.remove(preset.steps.get(info.position));
       adapter.notifyDataSetChanged();
       return true;
     default:
       return super.onContextItemSelected(item);
   }
 }
예제 #2
0
 @SuppressWarnings("unchecked")
 public void onItemClick(AdapterView parent, View v, int position, long id) {
   if (id == -1) {
     selectedStep = preset.blankStep();
     preset.addStep(selectedStep);
   } else {
     selectedStep = (DarkroomPreset.DarkroomStep) parent.getItemAtPosition(position);
   }
   modifiedStep = selectedStep.clone();
   showDialog(EDIT_STEP);
 }