]> iEval git - unical.git/commitdiff
Work on delete event to finish activity
authorPetru <l3asketballplayer@yahoo.com>
Thu, 15 Aug 2013 18:19:24 +0000 (21:19 +0300)
committerPetru <l3asketballplayer@yahoo.com>
Thu, 15 Aug 2013 18:19:24 +0000 (21:19 +0300)
src/ro/ieval/unical/DeleteEventDialog.java
src/ro/ieval/unical/DisplayEventActivity.java
src/ro/ieval/unical/EventListActivity.java

index 56e71cbdd97bf77cf820ff1a9c95058a8b1d83af..806db7e62cff69cf038d0eca76761caac24d4057 100644 (file)
@@ -10,24 +10,19 @@ import android.os.Bundle;
 
 @SuppressLint("ValidFragment")
 public final class DeleteEventDialog extends DialogFragment {
-       private final Event event;
-       private final Activity activity;
-
-       public DeleteEventDialog(final Event event, final Activity activity) {
-               super();
-               this.event=event;
-               this.activity=activity;
-       }
+       private Event event;
+    public boolean deleted=false;
 
        @Override
        public Dialog onCreateDialog(final Bundle savedInstanceState) {
                final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+        event=getArguments().getParcelable("Event");
                builder.setMessage(R.string.askdeleteevent)
                           .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                                   @Override
                                   public void onClick(final DialogInterface dialog, final int id) {
                                           event.delete(getActivity());
-                                          activity.finish();
+                                          deleted=true;
                                   }
                           })
                           .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
index 7e2e78f55f29424176a34a346ad440f666ece9eb..906ed5cddf77e7118f4f851469fefdbfdda71078 100644 (file)
@@ -16,6 +16,7 @@ import android.widget.TextView;
 public class DisplayEventActivity extends Activity {
        public static final String EXTRA_EVENT = "event";
        private Event event;
+    private final DeleteEventDialog d=new DeleteEventDialog();
 
        public static void displayEvent(final Context context, final Event event){
                final Intent i=new Intent(context,DisplayEventActivity.class);
@@ -55,6 +56,13 @@ public class DisplayEventActivity extends Activity {
                description.setText(event.description);
        }
 
+    @Override
+    protected void onResume () {
+        super.onResume();
+        if(d.deleted)
+            finish();
+    }
+
        @Override
        public boolean onCreateOptionsMenu(final Menu menu) {
                final MenuInflater inflater = getMenuInflater();
@@ -67,8 +75,11 @@ public class DisplayEventActivity extends Activity {
                // Handle item selection
                switch (item. getItemId()) {
                case R.id.deleteevent:
-                       final DeleteEventDialog d=new DeleteEventDialog(event,this);
+            final Bundle b=new Bundle();
+            b.putParcelable("Event",event);
+            d.setArguments(b);
                        d.show(getFragmentManager(), "Delete");
+
                        return true;
                case R.id.eventlist:
                        final Intent it=new Intent(this,EventListActivity.class);
index 652bd781eed1b50d7d18b02774998f5463e9771a..8763aebeb798ad0b3ace6e5594af4fe2f8620dfc 100644 (file)
@@ -74,6 +74,12 @@ public final class EventListActivity extends ListActivity {
                getListView().setSelectionFromTop(idx, 0);
        }
 
+    @Override
+    protected  void onStart() {
+        super.onStart();
+        displayEvents();
+    }
+
        @Override
        protected void onCreate(final Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
This page took 0.02678 seconds and 4 git commands to generate.