From: Erik Date: Thu, 25 Feb 2010 02:19:03 +0000 (-0800) Subject: b/2431102 Added check on save to ensure a valid calendar was selected. X-Git-Tag: android-x86-2.2~65 X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fpackages-apps-Calendar.git;a=commitdiff_plain;h=610380d597b3efa3c7c4e0caa023d4ed54b468bf b/2431102 Added check on save to ensure a valid calendar was selected. EditEvent performs a background query to get the list of calendars available before setting a default calendar. This made it possible to hit done on an event before any calendars could be set. Added a check to ensure a valid calendar has been selected before a save operation is performed on an event. --- diff --git a/src/com/android/calendar/EditEvent.java b/src/com/android/calendar/EditEvent.java index 15ee1f3..e907a6f 100644 --- a/src/com/android/calendar/EditEvent.java +++ b/src/com/android/calendar/EditEvent.java @@ -69,6 +69,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.Window; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; @@ -1381,11 +1382,12 @@ public class EditEvent extends Activity implements View.OnClickListener, return false; } - // Avoid creating a new event if the calendars cursor is empty. This - // shouldn't ever happen since the setup wizard should ensure the user - // has a calendar. - if (mCalendarsCursor == null || mCalendarsCursor.getCount() == 0) { - Log.w("Cal", "The calendars table does not contain any calendars." + // Avoid creating a new event if the calendars cursor is empty or we clicked through + // too quickly and no calendar was selected (blame the monkey) + if (mCalendarsCursor == null || mCalendarsCursor.getCount() == 0 || + mCalendarsSpinner.getSelectedItemId() == AdapterView.INVALID_ROW_ID) { + Log.w("Cal", "The calendars table does not contain any calendars" + + " or no calendar was selected." + " New event was not created."); return true; }