diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-10-05 18:26:19 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-10-05 18:26:19 +0000 |
commit | fd4264b2b52e294ccb1326784bdf1df2cd7fe14c (patch) | |
tree | 78055280c9526ccf6a7826a1ff9546d08fbeffb6 /src/com/android/launcher3/util | |
parent | bbb1aea148270947cef90fe1c8d0ad5961ef392e (diff) | |
parent | d1a0e8b5c8494945fe48c19fe0e13b6b161b90a7 (diff) | |
download | android_packages_apps_Trebuchet-fd4264b2b52e294ccb1326784bdf1df2cd7fe14c.tar.gz android_packages_apps_Trebuchet-fd4264b2b52e294ccb1326784bdf1df2cd7fe14c.tar.bz2 android_packages_apps_Trebuchet-fd4264b2b52e294ccb1326784bdf1df2cd7fe14c.zip |
Merge "Jailing the saved instance state of all the dynamically generated views" into ub-launcher3-burnaby-polish
Diffstat (limited to 'src/com/android/launcher3/util')
-rw-r--r-- | src/com/android/launcher3/util/ParcelableSparseArray.java | 52 |
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]; + } + }; +} |