Protect against NPE querying calendar cursors

pull/14/head
Tim Su 16 years ago
parent ec049d2ae5
commit 71fe5cff40

@ -10,15 +10,15 @@ import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.Toast; import android.widget.Toast;
import android.widget.CompoundButton.OnCheckedChangeListener;
import com.flurry.android.FlurryAgent; import com.flurry.android.FlurryAgent;
import com.timsu.astrid.R; import com.timsu.astrid.R;
@ -93,7 +93,7 @@ public class GCalControlSet implements TaskEditControlSet {
Intent intent = new Intent(Intent.ACTION_EDIT, calendarUri); Intent intent = new Intent(Intent.ACTION_EDIT, calendarUri);
try { try {
if(cursor.getCount() == 0) { if(cursor == null || cursor.getCount() == 0) {
// event no longer exists, recreate it // event no longer exists, recreate it
calendarUri = null; calendarUri = null;
writeToModel(myTask); writeToModel(myTask);
@ -106,6 +106,7 @@ public class GCalControlSet implements TaskEditControlSet {
Log.e("gcal-error", "Error opening calendar", e); //$NON-NLS-1$ //$NON-NLS-2$ Log.e("gcal-error", "Error opening calendar", e); //$NON-NLS-1$ //$NON-NLS-2$
Toast.makeText(activity, R.string.gcal_TEA_error, Toast.LENGTH_LONG); Toast.makeText(activity, R.string.gcal_TEA_error, Toast.LENGTH_LONG);
} finally { } finally {
if(cursor != null)
cursor.close(); cursor.close();
} }

Loading…
Cancel
Save