summaryrefslogtreecommitdiffstats
path: root/core/java/android/os/ParcelableParcel.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2013-04-26 16:39:17 -0700
committerDianne Hackborn <hackbod@google.com>2013-05-07 15:05:09 -0700
commit3aa49b6fece334ace7525d42c1f6d0b7cdc1fbfb (patch)
tree8b04d1e7dff2b31f68a60bc43949344f24ba564a /core/java/android/os/ParcelableParcel.java
parent2ae118d1077bcec1c407b6ecb9acf14e2152fe93 (diff)
downloadframeworks_base-3aa49b6fece334ace7525d42c1f6d0b7cdc1fbfb.zip
frameworks_base-3aa49b6fece334ace7525d42c1f6d0b7cdc1fbfb.tar.gz
frameworks_base-3aa49b6fece334ace7525d42c1f6d0b7cdc1fbfb.tar.bz2
New UndoManager.
Basic implementation of an undo manager. Supports multi-level undo/redo, building on the top undo state as edits occur, managing multiple distinct entities in the undo state (such as embedded objects in a document), and saving/restoring the full undo state. Still some work remaining on correctly dealing with dependencies between undo states that hold multiple owners. Also do a simple implementation of undo state in TextView to see how things actually work. The implementation here is very primitive: it needs a lot more work to correctly identify when to merge undo ops, is not trying to do anything smart with style spans, etc. Change-Id: Ie30f4e133351e2f569ffb48c6c44a2b19cadee27
Diffstat (limited to 'core/java/android/os/ParcelableParcel.java')
-rw-r--r--core/java/android/os/ParcelableParcel.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/core/java/android/os/ParcelableParcel.java b/core/java/android/os/ParcelableParcel.java
new file mode 100644
index 0000000..11785f1
--- /dev/null
+++ b/core/java/android/os/ParcelableParcel.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2013 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 android.os;
+
+/**
+ * Parcelable containing a raw Parcel of data.
+ * @hide
+ */
+public class ParcelableParcel implements Parcelable {
+ final Parcel mParcel;
+ final ClassLoader mClassLoader;
+
+ public ParcelableParcel(ClassLoader loader) {
+ mParcel = Parcel.obtain();
+ mClassLoader = loader;
+ }
+
+ public ParcelableParcel(Parcel src, ClassLoader loader) {
+ mParcel = Parcel.obtain();
+ mClassLoader = loader;
+ int size = src.readInt();
+ int pos = src.dataPosition();
+ mParcel.appendFrom(src, src.dataPosition(), size);
+ src.setDataPosition(pos + size);
+ }
+
+ public Parcel getParcel() {
+ mParcel.setDataPosition(0);
+ return mParcel;
+ }
+
+ public ClassLoader getClassLoader() {
+ return mClassLoader;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mParcel.dataSize());
+ dest.appendFrom(mParcel, 0, mParcel.dataSize());
+ }
+
+ public static final Parcelable.ClassLoaderCreator<ParcelableParcel> CREATOR
+ = new Parcelable.ClassLoaderCreator<ParcelableParcel>() {
+ public ParcelableParcel createFromParcel(Parcel in) {
+ return new ParcelableParcel(in, null);
+ }
+
+ public ParcelableParcel createFromParcel(Parcel in, ClassLoader loader) {
+ return new ParcelableParcel(in, loader);
+ }
+
+ public ParcelableParcel[] newArray(int size) {
+ return new ParcelableParcel[size];
+ }
+ };
+}