summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/util
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-08-27 17:45:46 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-10-05 18:25:49 +0000
commitd1a0e8b5c8494945fe48c19fe0e13b6b161b90a7 (patch)
tree83dc8d0882e72501b5e7a6d8fd0604d3cde314f6 /src/com/android/launcher3/util
parentde7ae659ff91badf1aca55eab4a810b80508c097 (diff)
downloadandroid_packages_apps_Trebuchet-d1a0e8b5c8494945fe48c19fe0e13b6b161b90a7.tar.gz
android_packages_apps_Trebuchet-d1a0e8b5c8494945fe48c19fe0e13b6b161b90a7.tar.bz2
android_packages_apps_Trebuchet-d1a0e8b5c8494945fe48c19fe0e13b6b161b90a7.zip
Jailing the saved instance state of all the dynamically generated views
Using itemId instead of generating a new id for each item. This is because if the process gets killed, View.generateId will get reset but we will still receive the generated item id map in onRestoreInstance. This will cause conflicts with newly generated item ids. We wrap all the generated homescreen views inside a single sparse array. This ensures that we do not cause any conflict with dynamically generated views in other parts of the UI. Bug: 16840760 Change-Id: I6fe69c2e1dd463402f51222715fae31b9d4dd240
Diffstat (limited to 'src/com/android/launcher3/util')
-rw-r--r--src/com/android/launcher3/util/ParcelableSparseArray.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/com/android/launcher3/util/ParcelableSparseArray.java b/src/com/android/launcher3/util/ParcelableSparseArray.java
new file mode 100644
index 000000000..093577e59
--- /dev/null
+++ b/src/com/android/launcher3/util/ParcelableSparseArray.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.util;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.SparseArray;
+
+public class ParcelableSparseArray extends SparseArray<Parcelable> implements Parcelable {
+ public int describeContents() {
+ return 0;
+ }
+
+ public void writeToParcel(Parcel dest, int flags) {
+ final int count = size();
+ dest.writeInt(count);
+ for (int i = 0; i < count; i++) {
+ dest.writeInt(keyAt(i));
+ dest.writeParcelable(valueAt(i), 0);
+ }
+ }
+
+ public static final Parcelable.Creator<ParcelableSparseArray> CREATOR =
+ new Parcelable.Creator<ParcelableSparseArray>() {
+ public ParcelableSparseArray createFromParcel(Parcel source) {
+ final ParcelableSparseArray array = new ParcelableSparseArray();
+ final ClassLoader loader = array.getClass().getClassLoader();
+ final int count = source.readInt();
+ for (int i = 0; i < count; i++) {
+ array.put(source.readInt(), source.readParcelable(loader));
+ }
+ return array;
+ }
+
+ public ParcelableSparseArray[] newArray(int size) {
+ return new ParcelableSparseArray[size];
+ }
+ };
+}