Example usage for android.os Parcel setDataPosition

List of usage examples for android.os Parcel setDataPosition

Introduction

In this page you can find the example usage for android.os Parcel setDataPosition.

Prototype

public final void setDataPosition(int pos) 

Source Link

Document

Move the current read/write position in the parcel.

Usage

From source file:com.google.android.apps.dashclock.api.ExtensionData.java

private ExtensionData(Parcel in) {
    int parcelableVersion = in.readInt();
    int parcelableSize = in.readInt();
    int startPosition = in.dataPosition();
    if (parcelableVersion >= 1) {
        this.mVisible = (in.readInt() != 0);
        this.mIcon = in.readInt();
        this.mStatus = in.readString();
        if (TextUtils.isEmpty(this.mStatus)) {
            this.mStatus = null;
        }//from w  ww . j  a  v  a2  s  .c o  m
        this.mExpandedTitle = in.readString();
        if (TextUtils.isEmpty(this.mExpandedTitle)) {
            this.mExpandedTitle = null;
        }
        this.mExpandedBody = in.readString();
        if (TextUtils.isEmpty(this.mExpandedBody)) {
            this.mExpandedBody = null;
        }
        try {
            this.mClickIntent = Intent.parseUri(in.readString(), 0);
        } catch (URISyntaxException ignored) {
        }
    }
    if (parcelableVersion >= 2) {
        this.mContentDescription = in.readString();
        if (TextUtils.isEmpty(this.mContentDescription)) {
            this.mContentDescription = null;
        }
        String iconUriString = in.readString();
        this.mIconUri = TextUtils.isEmpty(iconUriString) ? null : Uri.parse(iconUriString);
    }
    // Only advance the data position if the parcelable version is >= 2. In v1 of the
    // parcelable, there was an awful bug where the parcelableSize was complete nonsense.
    if (parcelableVersion >= 2) {
        in.setDataPosition(startPosition + parcelableSize);
    }
}