From f580909cce85fcd4edbba928c795abb2e75564be Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 15 Jun 2013 18:08:54 +0300 Subject: [PATCH] Clean up --- src/ro/ieval/unical/DeleteEventDialog.java | 20 ++++++++++--------- src/ro/ieval/unical/DisplayEventActivity.java | 14 ++++++------- src/ro/ieval/unical/TrivialFragment.java | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/ro/ieval/unical/DeleteEventDialog.java b/src/ro/ieval/unical/DeleteEventDialog.java index ba2f9c4..56e71cb 100644 --- a/src/ro/ieval/unical/DeleteEventDialog.java +++ b/src/ro/ieval/unical/DeleteEventDialog.java @@ -10,8 +10,15 @@ import android.os.Bundle; @SuppressLint("ValidFragment") public final class DeleteEventDialog extends DialogFragment { - Event e; Activity a; - + private final Event event; + private final Activity activity; + + public DeleteEventDialog(final Event event, final Activity activity) { + super(); + this.event=event; + this.activity=activity; + } + @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); @@ -19,9 +26,8 @@ public final class DeleteEventDialog extends DialogFragment { .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int id) { - // Nothing happens here yet - e.delete(getActivity()); - a.finish(); + event.delete(getActivity()); + activity.finish(); } }) .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @@ -32,8 +38,4 @@ 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 f5bb146..bb819b9 100644 --- a/src/ro/ieval/unical/DisplayEventActivity.java +++ b/src/ro/ieval/unical/DisplayEventActivity.java @@ -15,7 +15,7 @@ import android.widget.TextView; public class DisplayEventActivity extends Activity { public static final String EXTRA_EVENT = "event"; - Event e; + private Event event; public static void displayEvent(final Context context, final Event event){ final Intent i=new Intent(context,DisplayEventActivity.class); @@ -26,9 +26,9 @@ public class DisplayEventActivity extends Activity { @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - e=getIntent().getParcelableExtra(EXTRA_EVENT); + event=getIntent().getParcelableExtra(EXTRA_EVENT); setContentView(R.layout.event_view); - setTitle(e.title); + setTitle(event.title); final TextView startDay= (TextView) findViewById(R.id.startday); final TextView endDay= (TextView) findViewById(R.id.endday); @@ -38,8 +38,8 @@ public class DisplayEventActivity extends Activity { final TextView endTime= (TextView) findViewById(R.id.endtime); final TextView description= (TextView) findViewById(R.id.event_view_description); - final Date start=new Date(e.dtstart); - final Date end=new Date(e.dtend); + final Date start=new Date(event.dtstart); + final Date end=new Date(event.dtend); final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.UK); final SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss", Locale.UK); final SimpleDateFormat dayOfWeekFormat = new SimpleDateFormat("EEEEEEE", Locale.UK); @@ -52,7 +52,7 @@ public class DisplayEventActivity extends Activity { startDate.setText(dateFormat.format(start)); startTime.setText(timeFormat.format(start)); endTime.setText(timeFormat.format(end)); - description.setText(e.description); + description.setText(event.description); } @Override @@ -71,7 +71,7 @@ public class DisplayEventActivity extends Activity { startActivity(i); return true; case R.id.deleteevent: - final DeleteEventDialog d=new DeleteEventDialog(e,this); + final DeleteEventDialog d=new DeleteEventDialog(event,this); d.show(getFragmentManager(), "Delete"); return true; case R.id.eventlist: diff --git a/src/ro/ieval/unical/TrivialFragment.java b/src/ro/ieval/unical/TrivialFragment.java index 23086ab..4a1c0b2 100644 --- a/src/ro/ieval/unical/TrivialFragment.java +++ b/src/ro/ieval/unical/TrivialFragment.java @@ -13,7 +13,7 @@ import android.widget.Switch; public final class TrivialFragment extends Fragment { private static class OnItemSelectedListener implements android.widget.AdapterView.OnItemSelectedListener{ - final View repeatCount; + private final View repeatCount; public OnItemSelectedListener(final View repeatCount) { this.repeatCount=repeatCount; } -- 2.39.2