diff options
author | Paul Sliwowski <psliwowski@google.com> | 2013-05-20 20:27:12 -0700 |
---|---|---|
committer | Paul Sliwowski <psliwowski@google.com> | 2013-05-21 14:47:47 -0700 |
commit | 1aba96aa9678633c22eb14490195177b059c574e (patch) | |
tree | 04923fffeb784bad7df0ef36e1c2d6e8aed8a8c9 /src | |
parent | 259000714bb271aef2f1b6507e21428d4101394f (diff) | |
download | android_packages_apps_Calendar-1aba96aa9678633c22eb14490195177b059c574e.tar.gz android_packages_apps_Calendar-1aba96aa9678633c22eb14490195177b059c574e.tar.bz2 android_packages_apps_Calendar-1aba96aa9678633c22eb14490195177b059c574e.zip |
Display error when a viewed event has been deleted.
Bug: 8766415
Add error message to EventInfoFragment when there is
no event to display. This state should only occur when
the event is deleted while viewing it.
Change-Id: I36c1592061c4d7f58d0c259d8179f44c8f5f67f0
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/calendar/EventInfoFragment.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/com/android/calendar/EventInfoFragment.java b/src/com/android/calendar/EventInfoFragment.java index 10436cf5..e73482cf 100644 --- a/src/com/android/calendar/EventInfoFragment.java +++ b/src/com/android/calendar/EventInfoFragment.java @@ -358,6 +358,7 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange private View mHeadlines; private ScrollView mScrollView; private View mLoadingMsgView; + private View mErrorMsgView; private ObjectAnimator mAnimateAlpha; private long mLoadingMsgStartTime; @@ -465,11 +466,8 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange switch (token) { case TOKEN_QUERY_EVENT: mEventCursor = Utils.matrixCursorFromCursor(cursor); - if (initEventCursor()) { - // The cursor is empty. This can happen if the event was - // deleted. - // FRAG_TODO we should no longer rely on Activity.finish() - activity.finish(); + if (!initEventCursor()) { + displayEventNotFound(); return; } if (!mCalendarColorInitialized) { @@ -907,6 +905,7 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange } mScrollView = (ScrollView) mView.findViewById(R.id.event_info_scroll_view); mLoadingMsgView = mView.findViewById(R.id.event_info_loading_msg); + mErrorMsgView = mView.findViewById(R.id.event_info_error_msg); mTitle = (TextView) mView.findViewById(R.id.title); mWhenDateTime = (TextView) mView.findViewById(R.id.when_datetime); mWhere = (TextView) mView.findViewById(R.id.where); @@ -955,6 +954,7 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange mLoadingMsgView.setAlpha(0); mScrollView.setAlpha(0); + mErrorMsgView.setVisibility(View.INVISIBLE); mLoadingMsgView.postDelayed(mLoadingMsgAlphaUpdater, LOADING_MSG_DELAY); // start loading the data @@ -1052,11 +1052,11 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange /** * Initializes the event cursor, which is expected to point to the first * (and only) result from a query. - * @return true if the cursor is empty. + * @return false if the cursor is empty, true otherwise */ private boolean initEventCursor() { if ((mEventCursor == null) || (mEventCursor.getCount() == 0)) { - return true; + return false; } mEventCursor.moveToFirst(); mEventId = mEventCursor.getInt(EVENT_INDEX_ID); @@ -1068,7 +1068,7 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange (mReminders != null && mReminders.size() > 0); mMaxReminders = mEventCursor.getInt(EVENT_INDEX_MAX_REMINDERS); mCalendarAllowedReminders = mEventCursor.getString(EVENT_INDEX_ALLOWED_REMINDERS); - return false; + return true; } @SuppressWarnings("fallthrough") @@ -1458,6 +1458,12 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange } } + private void displayEventNotFound() { + mErrorMsgView.setVisibility(View.VISIBLE); + mScrollView.setVisibility(View.GONE); + mLoadingMsgView.setVisibility(View.GONE); + } + private void updateEvent(View view) { if (mEventCursor == null || view == null) { return; @@ -1694,7 +1700,7 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange } AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_FOCUSED); - event.setClassName(getClass().getName()); + event.setClassName(EventInfoFragment.class.getName()); event.setPackageName(getActivity().getPackageName()); List<CharSequence> text = event.getText(); |