From 8a08d036704efadbfcd4f7c4be1721f915d929c9 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Mon, 10 Jun 2013 17:06:49 +0300 Subject: [PATCH] Clean up previous commit and tabify source files --- src/ro/ieval/unical/CalendarUtils.java | 19 ----- src/ro/ieval/unical/DeleteEventDialog.java | 32 ++++---- src/ro/ieval/unical/DisplayEventActivity.java | 79 +++++++++---------- src/ro/ieval/unical/EventAdapter.java | 26 +++--- src/ro/ieval/unical/EventListActivity.java | 21 +++-- src/ro/ieval/unical/MainActivity.java | 16 ++-- src/ro/ieval/unical/MySQLiteHelper.java | 8 +- 7 files changed, 90 insertions(+), 111 deletions(-) delete mode 100644 src/ro/ieval/unical/CalendarUtils.java diff --git a/src/ro/ieval/unical/CalendarUtils.java b/src/ro/ieval/unical/CalendarUtils.java deleted file mode 100644 index 40489a9..0000000 --- a/src/ro/ieval/unical/CalendarUtils.java +++ /dev/null @@ -1,19 +0,0 @@ -package ro.ieval.unical; - -import java.util.GregorianCalendar; - -import android.content.Context; -import android.content.res.Resources; - -public class CalendarUtils { - public static String DayToString(Context context, GregorianCalendar gc) { - int dc=gc.get(GregorianCalendar.DAY_OF_WEEK); - if(dc==GregorianCalendar.SUNDAY) return context.getString(R.string.sunday); - else if(dc==GregorianCalendar.MONDAY) return context.getString(R.string.monday); - else if(dc==GregorianCalendar.TUESDAY) return context.getString(R.string.tuesday); - else if(dc==GregorianCalendar.WEDNESDAY) return context.getString(R.string.wednesday); - else if(dc==GregorianCalendar.THURSDAY) return context.getString(R.string.thursday); - else if(dc==GregorianCalendar.FRIDAY) return context.getString(R.string.friday); - else return context.getString(R.string.saturday); - } -} diff --git a/src/ro/ieval/unical/DeleteEventDialog.java b/src/ro/ieval/unical/DeleteEventDialog.java index a076507..8dc2267 100644 --- a/src/ro/ieval/unical/DeleteEventDialog.java +++ b/src/ro/ieval/unical/DeleteEventDialog.java @@ -8,21 +8,21 @@ import android.os.Bundle; public final class DeleteEventDialog extends DialogFragment { @Override - public Dialog onCreateDialog(final Bundle savedInstanceState) { - final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setMessage(R.string.askdeleteevent) - .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { - @Override - public void onClick(final DialogInterface dialog, final int id) { + public Dialog onCreateDialog(final Bundle savedInstanceState) { + final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setMessage(R.string.askdeleteevent) + .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(final DialogInterface dialog, final int id) { - } - }) - .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { - @Override - public void onClick(final DialogInterface dialog, final int id) { - // User cancelled the dialog - } - }); - return builder.create(); - } + } + }) + .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { + @Override + public void onClick(final DialogInterface dialog, final int id) { + // User cancelled the dialog + } + }); + return builder.create(); + } } diff --git a/src/ro/ieval/unical/DisplayEventActivity.java b/src/ro/ieval/unical/DisplayEventActivity.java index 8055ec1..df885ca 100644 --- a/src/ro/ieval/unical/DisplayEventActivity.java +++ b/src/ro/ieval/unical/DisplayEventActivity.java @@ -2,7 +2,7 @@ package ro.ieval.unical; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.GregorianCalendar; +import java.util.Locale; import android.app.Activity; import android.content.Context; @@ -29,55 +29,54 @@ public class DisplayEventActivity extends Activity { setContentView(R.layout.event_view); setTitle(e.title); - final TextView startday= (TextView) findViewById(R.id.startday); - final TextView endday= (TextView) findViewById(R.id.endday); - final TextView startdate= (TextView) findViewById(R.id.startdate); - final TextView enddate= (TextView) findViewById(R.id.enddate); - final TextView starttime= (TextView) findViewById(R.id.starttime); - final TextView endtime= (TextView) findViewById(R.id.endtime); - - GregorianCalendar cstart = new GregorianCalendar(); - cstart.setTime(new Date(e.dtstart)); - GregorianCalendar cend = new GregorianCalendar(); - cend.setTime(new Date(e.dtend)); - SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); - SimpleDateFormat stf = new SimpleDateFormat("kk:mm:ss"); - - startday.setText(CalendarUtils.DayToString(this,cstart)); - if(CalendarUtils.DayToString(this,cstart)!=CalendarUtils.DayToString(this, cend)) - endday.setText(CalendarUtils.DayToString(this, cend)); - startdate.setText(sdf.format(cstart.getTime())); - if(sdf.format(cstart.getTime())!=sdf.format(cend.getTime())) - enddate.setText(sdf.format(cend.getTime())); - starttime.setText(stf.format(cstart.getTime())); - endtime.setText(stf.format(cend.getTime())); + final TextView startDay= (TextView) findViewById(R.id.startday); + final TextView endDay= (TextView) findViewById(R.id.endday); + final TextView startDate= (TextView) findViewById(R.id.startdate); + final TextView endDate= (TextView) findViewById(R.id.enddate); + final TextView startTime= (TextView) findViewById(R.id.starttime); + final TextView endTime= (TextView) findViewById(R.id.endtime); + + final Date start=new Date(e.dtstart); + final Date end=new Date(e.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("E", Locale.UK); + + startDay.setText(dayOfWeekFormat.format(start)); + if(dayOfWeekFormat.format(start)!=dayOfWeekFormat.format(end)) + endDay.setText(dayOfWeekFormat.format(end)); + startDate.setText(dateFormat.format(start)); + if(dateFormat.format(start)!=dateFormat.format(end)) + endDate.setText(dateFormat.format(end)); + startTime.setText(timeFormat.format(start)); + endTime.setText(timeFormat.format(end)); } @Override public boolean onCreateOptionsMenu(final Menu menu) { final MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.event, menu); + inflater.inflate(R.menu.event, menu); return true; } @Override public boolean onOptionsItemSelected(final MenuItem item) { - // Handle item selection - switch (item. getItemId()) { - case R.id.NewEvent: - final Intent i=new Intent(this,AddEventActivity.class); + // Handle item selection + switch (item. getItemId()) { + case R.id.NewEvent: + final Intent i=new Intent(this,AddEventActivity.class); startActivity(i); - return true; - case R.id.deleteevent: - final DeleteEventDialog d=new DeleteEventDialog(); - d.show(getFragmentManager(), "Delete"); - return true; - case R.id.eventlist: - final Intent it=new Intent(this,EventListActivity.class); - startActivity(it); - return true; - default: - return true; - } + return true; + case R.id.deleteevent: + final DeleteEventDialog d=new DeleteEventDialog(); + d.show(getFragmentManager(), "Delete"); + return true; + case R.id.eventlist: + final Intent it=new Intent(this,EventListActivity.class); + startActivity(it); + return true; + default: + return true; + } } } diff --git a/src/ro/ieval/unical/EventAdapter.java b/src/ro/ieval/unical/EventAdapter.java index b06e08a..7aa4833 100644 --- a/src/ro/ieval/unical/EventAdapter.java +++ b/src/ro/ieval/unical/EventAdapter.java @@ -21,18 +21,18 @@ public class EventAdapter extends ArrayAdapter { @Override public View getView(final int position, final View convertView, final ViewGroup parent) { - final LayoutInflater inflater = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - final View rowView = inflater.inflate(R.layout.event_row_layout, parent, false); - final TextView title = (TextView) rowView.findViewById(R.id.smalleventtitle); - final TextView dstart = (TextView) rowView.findViewById(R.id.smalldatestart); - final TextView dend = (TextView) rowView.findViewById(R.id.smalldateend); - final View header = rowView.findViewById(R.id.rowHeader); - header.setBackgroundColor(values[position].eventColour); - title.setText(values[position].title); - dstart.setText(new Date(values[position].dtstart).toString()); - dend.setText(new Date(values[position].dtend).toString()); - - return rowView; + final LayoutInflater inflater = (LayoutInflater) context + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + final View rowView = inflater.inflate(R.layout.event_row_layout, parent, false); + final TextView title = (TextView) rowView.findViewById(R.id.smalleventtitle); + final TextView dstart = (TextView) rowView.findViewById(R.id.smalldatestart); + final TextView dend = (TextView) rowView.findViewById(R.id.smalldateend); + final View header = rowView.findViewById(R.id.rowHeader); + header.setBackgroundColor(values[position].eventColour); + title.setText(values[position].title); + dstart.setText(new Date(values[position].dtstart).toString()); + dend.setText(new Date(values[position].dtend).toString()); + + return rowView; } } diff --git a/src/ro/ieval/unical/EventListActivity.java b/src/ro/ieval/unical/EventListActivity.java index cb2ee6d..c9ccd44 100644 --- a/src/ro/ieval/unical/EventListActivity.java +++ b/src/ro/ieval/unical/EventListActivity.java @@ -18,14 +18,13 @@ import android.widget.ListView; public class EventListActivity extends Activity { - long dtstart,dtend; //Used to refresh events if the user wants to display only certain events //Sry for bad english //Muie la comisie private void displayEvents() { final Event events[]=Event.getAllEvents(getBaseContext()); - final ListView lv = (ListView) findViewById(R.id.eventlist); - + final ListView lv = (ListView) findViewById(R.id.eventlist); + Arrays.sort(events,new EventComparator()); int idx=-1;//index of the first event to be displayed for(int i=0; i