private void refresh() { eventAdapter.refresh(); }
@Override public boolean onEventLongClick( AdapterView<?> parent, View v, final int position, final long id) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder .setTitle(eventAdapter.getItem(position).getTitle()) .setItems( R.array.manage_events_event_actions, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent; switch (which) { case 0: // Anzeigen intent = new Intent(ManageEventsActivity.this, ShowEventActivity.class); intent.putExtra(ShowEventActivity.EXTRA_EVENT_ID, id); startActivity(intent); break; case 1: // Bearbeiten intent = new Intent(ManageEventsActivity.this, EditEventActivity.class); intent.putExtra(EditEventActivity.EXTRA_EVENT_ID, id); startActivity(intent); break; case 2: // Teilnehmer bearbeiten intent = new Intent( ManageEventsActivity.this, ManageEventParticipantsActivity.class); intent.putExtra(ManageEventParticipantsActivity.EXTRA_EVENT_ID, id); startActivity(intent); break; case 3: // Löschen AlertDialog.Builder builder = new AlertDialog.Builder(ManageEventsActivity.this); builder .setTitle(R.string.delete_event) .setMessage(R.string.delete_event_message) .setPositiveButton( R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startLoading(); EventController.deleteEvent( new ExtendedTaskDelegateAdapter<Void, Void>() { @Override public void taskDidFinish(ExtendedTask task, Void aVoid) { eventAdapter.removeItem(position); finishLoading(); } @Override public void taskFailed(ExtendedTask task, String message) { Toast.makeText( ManageEventsActivity.this, message, Toast.LENGTH_LONG) .show(); finishLoading(); } }, id); } }) .setNegativeButton( R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.create().show(); break; } } }); builder.create().show(); return true; }