No crash on color change and orientation change
Bug: 9005546
Change-Id: I0830d4dd9fbbeaa9f79c9295eb5dd7bad70d979b
diff --git a/src/com/android/calendar/EventInfoFragment.java b/src/com/android/calendar/EventInfoFragment.java
index 613ba6b..10436cf 100644
--- a/src/com/android/calendar/EventInfoFragment.java
+++ b/src/com/android/calendar/EventInfoFragment.java
@@ -134,6 +134,7 @@
protected static final String BUNDLE_KEY_CALENDAR_COLOR = "key_calendar_color";
protected static final String BUNDLE_KEY_CALENDAR_COLOR_INIT = "key_calendar_color_init";
protected static final String BUNDLE_KEY_CURRENT_COLOR = "key_current_color";
+ protected static final String BUNDLE_KEY_CURRENT_COLOR_KEY = "key_current_color_key";
protected static final String BUNDLE_KEY_CURRENT_COLOR_INIT = "key_current_color_init";
protected static final String BUNDLE_KEY_ORIGINAL_COLOR = "key_original_color";
protected static final String BUNDLE_KEY_ORIGINAL_COLOR_INIT = "key_original_color_init";
@@ -369,6 +370,7 @@
private boolean mCalendarColorInitialized = false;
private int mCurrentColor = -1;
private boolean mCurrentColorInitialized = false;
+ private int mCurrentColorKey = -1;
private static final int FADE_IN_TIME = 300; // in milliseconds
private static final int LOADING_MSG_DELAY = 600; // in milliseconds
@@ -873,6 +875,7 @@
mCurrentColor = savedInstanceState.getInt(BUNDLE_KEY_CURRENT_COLOR);
mCurrentColorInitialized = savedInstanceState.getBoolean(
BUNDLE_KEY_CURRENT_COLOR_INIT);
+ mCurrentColorKey = savedInstanceState.getInt(BUNDLE_KEY_CURRENT_COLOR_KEY);
mTentativeUserSetResponse = savedInstanceState.getInt(
BUNDLE_KEY_TENTATIVE_USER_RESPONSE,
@@ -1160,6 +1163,7 @@
outState.putBoolean(BUNDLE_KEY_ORIGINAL_COLOR_INIT, mOriginalColorInitialized);
outState.putInt(BUNDLE_KEY_CURRENT_COLOR, mCurrentColor);
outState.putBoolean(BUNDLE_KEY_CURRENT_COLOR_INIT, mCurrentColorInitialized);
+ outState.putInt(BUNDLE_KEY_CURRENT_COLOR_KEY, mCurrentColorKey);
// We'll need the temporary response for configuration changes.
outState.putInt(BUNDLE_KEY_TENTATIVE_USER_RESPONSE, mTentativeUserSetResponse);
@@ -1268,7 +1272,7 @@
ContentValues values = new ContentValues();
if (mCurrentColor != mCalendarColor) {
- values.put(Events.EVENT_COLOR_KEY, mDisplayColorKeyMap.get(mCurrentColor));
+ values.put(Events.EVENT_COLOR_KEY, mCurrentColorKey);
} else {
values.put(Events.EVENT_COLOR_KEY, NO_EVENT_COLOR);
}
@@ -1282,6 +1286,7 @@
public void onStop() {
Activity act = getActivity();
if (!mEventDeletionStarted && act != null && !act.isChangingConfigurations()) {
+
boolean responseSaved = saveResponse();
boolean eventColorSaved = saveEventColor();
if (saveReminders() || responseSaved || eventColorSaved) {
@@ -1453,11 +1458,6 @@
}
}
- private void updateCurrentEventColor(int color) {
- mCurrentColor = color;
- mHeadlines.setBackgroundColor(color);
- }
-
private void updateEvent(View view) {
if (mEventCursor == null || view == null) {
return;
@@ -1506,7 +1506,7 @@
String rRule = mEventCursor.getString(EVENT_INDEX_RRULE);
String eventTimezone = mEventCursor.getString(EVENT_INDEX_EVENT_TIMEZONE);
- updateCurrentEventColor(mCurrentColor);
+ mHeadlines.setBackgroundColor(mCurrentColor);
// What
if (eventName != null) {
@@ -2285,6 +2285,8 @@
@Override
public void onColorSelected(int color) {
- updateCurrentEventColor(color);
+ mCurrentColor = color;
+ mCurrentColorKey = mDisplayColorKeyMap.get(color);
+ mHeadlines.setBackgroundColor(color);
}
}