diff options
Diffstat (limited to 'src/java/cyanogenmod/app/CustomTile.java')
-rw-r--r-- | src/java/cyanogenmod/app/CustomTile.java | 90 |
1 files changed, 30 insertions, 60 deletions
diff --git a/src/java/cyanogenmod/app/CustomTile.java b/src/java/cyanogenmod/app/CustomTile.java index 26ff6b4..dee8c37 100644 --- a/src/java/cyanogenmod/app/CustomTile.java +++ b/src/java/cyanogenmod/app/CustomTile.java @@ -28,6 +28,9 @@ import android.util.Log; import android.widget.RemoteViews; import cyanogenmod.os.Build; +import cyanogenmod.os.Concierge; +import cyanogenmod.os.Concierge.ParcelInfo; + import java.util.ArrayList; /** @@ -128,11 +131,9 @@ public class CustomTile implements Parcelable { * Unflatten the CustomTile from a parcel. */ public CustomTile(Parcel parcel) { - // Read parcelable version, make sure to define explicit changes - // within {@link Build.PARCELABLE_VERSION); - int parcelableVersion = parcel.readInt(); - int parcelableSize = parcel.readInt(); - int startPosition = parcel.dataPosition(); + // Read parcelable version via the Concierge + ParcelInfo parcelInfo = Concierge.receiveParcel(parcel); + int parcelableVersion = parcelInfo.getParcelVersion(); // Pattern here is that all new members should be added to the end of // the writeToParcel method. Then we step through each version, until the latest @@ -177,7 +178,8 @@ public class CustomTile implements Parcelable { } } - parcel.setDataPosition(startPosition + parcelableSize); + // Complete parcel info for the concierge + parcelInfo.complete(); } /** @@ -267,15 +269,8 @@ public class CustomTile implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { - // Write parcelable version, make sure to define explicit changes - // within {@link Build.PARCELABLE_VERSION); - out.writeInt(Build.PARCELABLE_VERSION); - - // Inject a placeholder that will store the parcel size from this point on - // (not including the size itself). - int sizePosition = out.dataPosition(); - out.writeInt(0); - int startPosition = out.dataPosition(); + // Tell the concierge to prepare the parcel + ParcelInfo parcelInfo = Concierge.prepareParcel(out); // ==== APRICOT ===== if (onClick != null) { @@ -341,11 +336,8 @@ public class CustomTile implements Parcelable { out.writeInt(0); } - // Go back and write size - int parcelableSize = out.dataPosition() - startPosition; - out.setDataPosition(sizePosition); - out.writeInt(parcelableSize); - out.setDataPosition(startPosition + parcelableSize); + // Complete the parcel info for the concierge + parcelInfo.complete(); } /** @@ -382,11 +374,9 @@ public class CustomTile implements Parcelable { private int styleId; private ExpandedStyle(Parcel parcel) { - // Read parcelable version, make sure to define explicit changes - // within {@link Build.PARCELABLE_VERSION); - int parcelableVersion = parcel.readInt(); - int parcelableSize = parcel.readInt(); - int startPosition = parcel.dataPosition(); + // Read parcelable version via the Concierge + ParcelInfo parcelInfo = Concierge.receiveParcel(parcel); + int parcelableVersion = parcelInfo.getParcelVersion(); // Pattern here is that all new members should be added to the end of // the writeToParcel method. Then we step through each version, until the latest @@ -404,7 +394,8 @@ public class CustomTile implements Parcelable { } } - parcel.setDataPosition(startPosition + parcelableSize); + // Complete parcel info for the concierge + parcelInfo.complete(); } /** @@ -473,15 +464,8 @@ public class CustomTile implements Parcelable { @Override public void writeToParcel(Parcel parcel, int i) { - // Write parcelable version, make sure to define explicit changes - // within {@link Build.PARCELABLE_VERSION); - parcel.writeInt(Build.PARCELABLE_VERSION); - - // Inject a placeholder that will store the parcel size from this point on - // (not including the size itself). - int sizePosition = parcel.dataPosition(); - parcel.writeInt(0); - int startPosition = parcel.dataPosition(); + // Tell the concierge to prepare the parcel + ParcelInfo parcelInfo = Concierge.prepareParcel(parcel); // ==== APRICOT ==== if (expandedItems != null) { @@ -500,11 +484,8 @@ public class CustomTile implements Parcelable { parcel.writeInt(0); } - // Go back and write size - int parcelableSize = parcel.dataPosition() - startPosition; - parcel.setDataPosition(sizePosition); - parcel.writeInt(parcelableSize); - parcel.setDataPosition(startPosition + parcelableSize); + // Complete the parcel info for the concierge + parcelInfo.complete(); } @Override @@ -679,11 +660,9 @@ public class CustomTile implements Parcelable { * Unflatten the ExpandedItem from a parcel. */ protected ExpandedItem(Parcel parcel) { - // Read parcelable version, make sure to define explicit changes - // within {@link Build.PARCELABLE_VERSION); - int parcelableVersion = parcel.readInt(); - int parcelableSize = parcel.readInt(); - int startPosition = parcel.dataPosition(); + // Read parcelable version via the Concierge + ParcelInfo parcelInfo = Concierge.receiveParcel(parcel); + int parcelableVersion = parcelInfo.getParcelVersion(); // Pattern here is that all new members should be added to the end of // the writeToParcel method. Then we step through each version, until the latest @@ -707,7 +686,8 @@ public class CustomTile implements Parcelable { } } - parcel.setDataPosition(startPosition + parcelableSize); + // Complete parcel info for the concierge + parcelInfo.complete(); } @Override @@ -717,15 +697,8 @@ public class CustomTile implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { - // Write parcelable version, make sure to define explicit changes - // within {@link Build.PARCELABLE_VERSION); - out.writeInt(Build.PARCELABLE_VERSION); - - // Inject a placeholder that will store the parcel size from this point on - // (not including the size itself). - int sizePosition = out.dataPosition(); - out.writeInt(0); - int startPosition = out.dataPosition(); + // Tell the concierge to prepare the parcel + ParcelInfo parcelInfo = Concierge.prepareParcel(out); // ==== APRICOT ==== if (onClickPendingIntent != null) { @@ -756,11 +729,8 @@ public class CustomTile implements Parcelable { out.writeInt(0); } - // Go back and write size - int parcelableSize = out.dataPosition() - startPosition; - out.setDataPosition(sizePosition); - out.writeInt(parcelableSize); - out.setDataPosition(startPosition + parcelableSize); + // Complete the parcel info for the concierge + parcelInfo.complete(); } @Override |