From: Petru Trimbitas Date: Sat, 15 Jun 2013 15:04:28 +0000 (+0300) Subject: Delete Event now works X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=dd76f98a4950d7e2ae3dca98eba1579dac4a340a;p=unical.git Delete Event now works --- diff --git a/src/ro/ieval/unical/DeleteEventDialog.java b/src/ro/ieval/unical/DeleteEventDialog.java index 40fe582..ba2f9c4 100644 --- a/src/ro/ieval/unical/DeleteEventDialog.java +++ b/src/ro/ieval/unical/DeleteEventDialog.java @@ -1,12 +1,17 @@ package ro.ieval.unical; +import android.annotation.SuppressLint; +import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.content.DialogInterface; import android.os.Bundle; +@SuppressLint("ValidFragment") public final class DeleteEventDialog extends DialogFragment { + Event e; Activity a; + @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); @@ -15,6 +20,8 @@ public final class DeleteEventDialog extends DialogFragment { @Override public void onClick(final DialogInterface dialog, final int id) { // Nothing happens here yet + e.delete(getActivity()); + a.finish(); } }) .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @@ -25,4 +32,8 @@ public final class DeleteEventDialog extends DialogFragment { }); return builder.create(); } + public DeleteEventDialog(Event e,Activity a) { + this.e=e; + this.a=a; + } } diff --git a/src/ro/ieval/unical/DisplayEventActivity.java b/src/ro/ieval/unical/DisplayEventActivity.java index 967a556..f5bb146 100644 --- a/src/ro/ieval/unical/DisplayEventActivity.java +++ b/src/ro/ieval/unical/DisplayEventActivity.java @@ -15,6 +15,7 @@ import android.widget.TextView; public class DisplayEventActivity extends Activity { public static final String EXTRA_EVENT = "event"; + Event e; public static void displayEvent(final Context context, final Event event){ final Intent i=new Intent(context,DisplayEventActivity.class); @@ -25,7 +26,7 @@ public class DisplayEventActivity extends Activity { @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - final Event e=getIntent().getParcelableExtra(EXTRA_EVENT); + e=getIntent().getParcelableExtra(EXTRA_EVENT); setContentView(R.layout.event_view); setTitle(e.title); @@ -70,7 +71,7 @@ public class DisplayEventActivity extends Activity { startActivity(i); return true; case R.id.deleteevent: - final DeleteEventDialog d=new DeleteEventDialog(); + final DeleteEventDialog d=new DeleteEventDialog(e,this); d.show(getFragmentManager(), "Delete"); return true; case R.id.eventlist: