From: Petru Date: Sun, 25 Aug 2013 18:18:44 +0000 (+0300) Subject: Removes repeat layout. Format date now works correctly X-Git-Url: http://git.ieval.ro/?p=unical.git;a=commitdiff_plain;h=0a4f300ecd7de6e7cac1e2f90cf01d1c60a0f1f3 Removes repeat layout. Format date now works correctly --- diff --git a/res/layout/add_event.xml b/res/layout/add_event.xml index c1f73ad..d9f2adf 100644 --- a/res/layout/add_event.xml +++ b/res/layout/add_event.xml @@ -104,80 +104,8 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ro/ieval/unical/AddEventActivity.java b/src/ro/ieval/unical/AddEventActivity.java index 80f7a04..b86dd77 100644 --- a/src/ro/ieval/unical/AddEventActivity.java +++ b/src/ro/ieval/unical/AddEventActivity.java @@ -26,55 +26,6 @@ import android.widget.*; public final class AddEventActivity extends Activity implements OnDateSetListener, OnTimeSetListener{ - private class OnCheckedChangeListener implements android.widget.CompoundButton.OnCheckedChangeListener{ - private final LinearLayout layout; - public OnCheckedChangeListener(final LinearLayout layout){ - this.layout=layout; - } - - private class OnItemSelectedListener implements android.widget.AdapterView.OnItemSelectedListener{ - private final View repeatCount; - private final View repeatUntil; - - public OnItemSelectedListener(final View repeatCount, final View repeatUntil) { - this.repeatCount=repeatCount; - this.repeatUntil=repeatUntil; - } - - @Override - public void onItemSelected(final AdapterView whatever, final View ignored, final int pos, final long id) { - switch(pos){ - case 0: - repeatCount.setVisibility(View.GONE); - repeatUntil.setVisibility(View.GONE); - break; - case 1: - repeatCount.setVisibility(View.GONE); - repeatUntil.setVisibility(View.VISIBLE); - break; - case 2: - repeatCount.setVisibility(View.VISIBLE); - repeatUntil.setVisibility(View.GONE); - break; - default: - } - } - - @Override public void onNothingSelected(final AdapterView arg0) { /* do nothing */ } - } - - @Override - public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { - if(isChecked) { - Utils.setEnabledRecursively(layout, true); - final Spinner repeatType = (Spinner) findViewById(R.id.repeat_type); - repeatType.setOnItemSelectedListener(new OnItemSelectedListener(findViewById(R.id.repeat_count),findViewById(R.id.repeat_until))); - }else { - Utils.setEnabledRecursively(layout, false); - } - } - } - private TextView dateTimeTextView; public static final String EXTRA_EVENT = "event"; private static Event event=new Event(); @@ -95,12 +46,6 @@ public final class AddEventActivity extends Activity implements OnDateSetListene final ActionBar actionBar = getActionBar(); setContentView(R.layout.add_event); - final LinearLayout layout = (LinearLayout) findViewById(R.id.repeat_layout); - final Switch repeatSwitch = (Switch) findViewById(R.id.repeat_switch); - Utils.setEnabledRecursively(layout, false); - - repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener(layout)); - final EditText title = (EditText) findViewById(R.id.eventtitle); title.requestFocus(); title.setText(event.title); @@ -201,7 +146,7 @@ public final class AddEventActivity extends Activity implements OnDateSetListene public void showDateTimePickerDialog(final View v) { dateTimeTextView=(TextView) v; - if(v.getId()==R.id.date_start || v.getId()==R.id.date_end || v.getId() == R.id.repeat_until){ + if(v.getId()==R.id.date_start || v.getId()==R.id.date_end ){ final String[] parts = dateTimeTextView.getText().toString().split("-"); final DatePickerFragment fragment = new DatePickerFragment(); final Bundle args = new Bundle(); diff --git a/src/ro/ieval/unical/Utils.java b/src/ro/ieval/unical/Utils.java index 3b53b47..b46078a 100644 --- a/src/ro/ieval/unical/Utils.java +++ b/src/ro/ieval/unical/Utils.java @@ -27,7 +27,7 @@ final class Utils { } public static String formatDate(final int year, final int month, final int day){ - return String.format(Locale.ENGLISH, "%4d-%02d-%02d", year, month, day); + return String.format(Locale.ENGLISH, "%4d-%02d-%02d", year, month+1, day); } public static void addAlarm(final Application application, final long time, final long eventId) throws SQLException{