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());
@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() {
});
return builder.create();
}
+ public DeleteEventDialog(Event e,Activity a) {
+ this.e=e;
+ this.a=a;
+ }
}
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);
@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);
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: