当前位置: 首页>>代码示例>>Java>>正文


Java Parcel.dataPosition方法代码示例

本文整理汇总了Java中android.os.Parcel.dataPosition方法的典型用法代码示例。如果您正苦于以下问题:Java Parcel.dataPosition方法的具体用法?Java Parcel.dataPosition怎么用?Java Parcel.dataPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.Parcel的用法示例。


在下文中一共展示了Parcel.dataPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeToParcel

import android.os.Parcel; //导入方法依赖的package包/类
public void writeToParcel(Parcel dest, int flags) {
    /**
     * NOTE: When adding fields in the process of updating this API, make sure to bump
     * {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();
    // version 1
    dest.writeInt(errorId);
    dest.writeString(message);
    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:21,代码来源:SMimeError.java

示例2: writeToParcel

import android.os.Parcel; //导入方法依赖的package包/类
public void writeToParcel(Parcel dest, int flags) {
    /**
     * NOTE: When adding fields in the process of updating this API, make sure to bump
     * {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();
    // version 1
    dest.writeInt(result);
    // version 2
    dest.writeByteArray(sessionKey);
    dest.writeByteArray(decryptedSessionKey);
    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:23,代码来源:SMimeDecryptionResult.java

示例3: createFromParcel

import android.os.Parcel; //导入方法依赖的package包/类
public SMimeDecryptionResult createFromParcel(final Parcel source) {
    int version = source.readInt(); // parcelableVersion
    int parcelableSize = source.readInt();
    int startPosition = source.dataPosition();

    int result = source.readInt();
    byte[] sessionKey = version > 1 ? source.createByteArray() : null;
    byte[] decryptedSessionKey = version > 1 ? source.createByteArray() : null;

    SMimeDecryptionResult vr = new SMimeDecryptionResult(result, sessionKey, decryptedSessionKey);

    // skip over all fields added in future versions of this parcel
    source.setDataPosition(startPosition + parcelableSize);

    return vr;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:17,代码来源:SMimeDecryptionResult.java

示例4: writeToParcel

import android.os.Parcel; //导入方法依赖的package包/类
public void writeToParcel(Parcel dest, int flags) {
    /**
     * NOTE: When adding fields in the process of updating this API, make sure to bump
     * {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();
    // version 1
    dest.writeString(filename);
    dest.writeString(mimeType);
    dest.writeLong(modificationTime);
    dest.writeLong(originalSize);
    // version 2
    dest.writeString(charset);
    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:25,代码来源:SMimeMetadata.java

示例5: createFromParcel

import android.os.Parcel; //导入方法依赖的package包/类
public SMimeMetadata createFromParcel(final Parcel source) {
    int version = source.readInt(); // parcelableVersion
    int parcelableSize = source.readInt();
    int startPosition = source.dataPosition();

    SMimeMetadata vr = new SMimeMetadata();
    vr.filename = source.readString();
    vr.mimeType = source.readString();
    vr.modificationTime = source.readLong();
    vr.originalSize = source.readLong();
    if (version >= 2) {
        vr.charset = source.readString();
    }

    // skip over all fields added in future versions of this parcel
    source.setDataPosition(startPosition + parcelableSize);

    return vr;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:20,代码来源:SMimeMetadata.java

示例6: createFromParcel

import android.os.Parcel; //导入方法依赖的package包/类
public OpenPgpMetadata createFromParcel(final Parcel source) {
    int version = source.readInt(); // parcelableVersion
    int parcelableSize = source.readInt();
    int startPosition = source.dataPosition();

    OpenPgpMetadata vr = new OpenPgpMetadata();
    vr.filename = source.readString();
    vr.mimeType = source.readString();
    vr.modificationTime = source.readLong();
    vr.originalSize = source.readLong();
    if (version >= 2) {
        vr.charset = source.readString();
    }

    // skip over all fields added in future versions of this parcel
    source.setDataPosition(startPosition + parcelableSize);

    return vr;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:20,代码来源:OpenPgpMetadata.java

示例7: createFromParcel

import android.os.Parcel; //导入方法依赖的package包/类
public OpenPgpDecryptionResult createFromParcel(final Parcel source) {
    int version = source.readInt(); // parcelableVersion
    int parcelableSize = source.readInt();
    int startPosition = source.dataPosition();

    int result = source.readInt();
    byte[] sessionKey = version > 1 ? source.createByteArray() : null;
    byte[] decryptedSessionKey = version > 1 ? source.createByteArray() : null;

    OpenPgpDecryptionResult vr = new OpenPgpDecryptionResult(result, sessionKey, decryptedSessionKey);

    // skip over all fields added in future versions of this parcel
    source.setDataPosition(startPosition + parcelableSize);

    return vr;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:17,代码来源:OpenPgpDecryptionResult.java

示例8: TaskData

import android.os.Parcel; //导入方法依赖的package包/类
private TaskData(Parcel in) {
    int parcelableSize = in.readInt();
    int startPosition = in.dataPosition();
    this.mSID = in.readLong();
    this.mTID = in.readLong();
    this.mContent = in.readString();
    this.mType = in.readString();
    this.mMethod = in.readString();
    if (TextUtils.isEmpty(this.mContent)) {
        this.mContent = null;
    }
    if (TextUtils.isEmpty(this.mType)) {
        this.mType = null;
    }
    if (TextUtils.isEmpty(this.mMethod)) {
        this.mMethod = null;
    }
}
 
开发者ID:MessageOnTap,项目名称:MessageOnTap_API,代码行数:19,代码来源:TaskData.java

示例9: writeToParcel

import android.os.Parcel; //导入方法依赖的package包/类
@Override
public void writeToParcel(Parcel parcel, int i) {
    // 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();
    parcel.writeLong(mSID);
    parcel.writeLong(mTID);
    parcel.writeString(TextUtils.isEmpty(mContent) ? "" : mContent);
    parcel.writeString(TextUtils.isEmpty(mType) ? "" : mType);
    parcel.writeString(TextUtils.isEmpty(mMethod) ? "" : mMethod);
    // Go back and write the size
    int parcelableSize = parcel.dataPosition() - startPosition;
    parcel.setDataPosition(sizePosition);
    parcel.writeInt(parcelableSize);
    parcel.setDataPosition(startPosition + parcelableSize);
}
 
开发者ID:MessageOnTap,项目名称:MessageOnTap_API,代码行数:19,代码来源:TaskData.java

示例10: createFromParcel

import android.os.Parcel; //导入方法依赖的package包/类
public SMimeError createFromParcel(final Parcel source) {
    source.readInt(); // parcelableVersion
    int parcelableSize = source.readInt();
    int startPosition = source.dataPosition();

    SMimeError error = new SMimeError();
    error.errorId = source.readInt();
    error.message = source.readString();

    // skip over all fields added in future versions of this parcel
    source.setDataPosition(startPosition + parcelableSize);

    return error;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:15,代码来源:SMimeError.java

示例11: writeToParcel

import android.os.Parcel; //导入方法依赖的package包/类
public void writeToParcel(Parcel dest, int flags) {
    /**
     * NOTE: When adding fields in the process of updating this API, make sure to bump
     * {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();
    // version 1
    dest.writeInt(result);
    // signatureOnly is deprecated since version 3. we pass a dummy value for compatibility
    dest.writeByte((byte) 0);
    dest.writeString(primaryUserId);
    dest.writeLong(keyId);
    // version 2
    dest.writeStringList(userIds);
    // version 3
    writeEnumWithNull(dest, senderStatusResult);
    dest.writeStringList(confirmedUserIds);
    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:29,代码来源:SMimeSignatureResult.java

示例12: createFromParcel

import android.os.Parcel; //导入方法依赖的package包/类
public OpenPgpError createFromParcel(final Parcel source) {
    source.readInt(); // parcelableVersion
    int parcelableSize = source.readInt();
    int startPosition = source.dataPosition();

    OpenPgpError error = new OpenPgpError();
    error.errorId = source.readInt();
    error.message = source.readString();

    // skip over all fields added in future versions of this parcel
    source.setDataPosition(startPosition + parcelableSize);

    return error;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:15,代码来源:OpenPgpError.java

示例13: writeToParcel

import android.os.Parcel; //导入方法依赖的package包/类
public void writeToParcel(Parcel dest, int flags) {
    /**
     * NOTE: When adding fields in the process of updating this API, make sure to bump
     * {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();

    // version 1
    dest.writeByteArray(keyData);
    if (effectiveDate != null) {
        dest.writeInt(1);
        dest.writeLong(effectiveDate.getTime());
    } else {
        dest.writeInt(0);
    }

    dest.writeInt(preferEncrypt.ordinal());

    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:30,代码来源:AutocryptPeerUpdate.java

示例14: parse

import android.os.Parcel; //导入方法依赖的package包/类
/**
 * Check a parcel containing metadata is well formed. The header
 * is checked as well as the individual records format. However, the
 * data inside the record is not checked because we do lazy access
 * (we check/unmarshall only data the user asks for.)
 *
 * Format of a metadata parcel:
 <pre>
                     1                   2                   3
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                     metadata total size                       |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |     'M'       |     'E'       |     'T'       |     'A'       |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                                                               |
  |                .... metadata records ....                     |
  |                                                               |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 </pre>
 *
 * @param parcel With the serialized data. Metadata keeps a
 *               reference on it to access it later on. The caller
 *               should not modify the parcel after this call (and
 *               not call recycle on it.)
 * @return false if an error occurred.
 * {@hide}
 */
public boolean parse(Parcel parcel) {
    if (parcel.dataAvail() < kMetaHeaderSize) {
        Log.e(TAG, "Not enough data " + parcel.dataAvail());
        return false;
    }

    final int pin = parcel.dataPosition();  // to roll back in case of errors.
    final int size = parcel.readInt();

    // The extra kInt32Size below is to account for the int32 'size' just read.
    if (parcel.dataAvail() + kInt32Size < size || size < kMetaHeaderSize) {
        Log.e(TAG, "Bad size " + size + " avail " + parcel.dataAvail() + " position " + pin);
        parcel.setDataPosition(pin);
        return false;
    }

    // Checks if the 'M' 'E' 'T' 'A' marker is present.
    final int kShouldBeMetaMarker = parcel.readInt();
    if (kShouldBeMetaMarker != kMetaMarker ) {
        Log.e(TAG, "Marker missing " + Integer.toHexString(kShouldBeMetaMarker));
        parcel.setDataPosition(pin);
        return false;
    }

    // Scan the records to collect metadata ids and offsets.
    if (!scanAllRecords(parcel, size - kMetaHeaderSize)) {
        parcel.setDataPosition(pin);
        return false;
    }
    mBegin = pin;
    mParcel = parcel;
    return true;
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:62,代码来源:MediaMetadata.java

示例15: scanAllRecords

import android.os.Parcel; //导入方法依赖的package包/类
/**
 * Go over all the records, collecting metadata keys and records'
 * type field offset in the Parcel. These are stored in
 * mKeyToPosMap for latter retrieval.
 * Format of a metadata record:
 <pre>
                     1                   2                   3
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                     record size                               |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                     metadata key                              |  // TITLE
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                     metadata type                             |  // STRING_VAL
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                                                               |
  |                .... metadata payload ....                     |
  |                                                               |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 </pre>
 * @param parcel With the serialized records.
 * @param bytesLeft How many bytes in the parcel should be processed.
 * @return false if an error occurred during parsing.
 */
private boolean scanAllRecords(Parcel parcel, int bytesLeft) {
    int recCount = 0;
    boolean error = false;

    mKeyToPosMap.clear();
    while (bytesLeft > kRecordHeaderSize) {
        final int start = parcel.dataPosition();
        // Check the size.
        final int size = parcel.readInt();

        if (size <= kRecordHeaderSize) {  // at least 1 byte should be present.
            Log.e(TAG, "Record is too short");
            error = true;
            break;
        }

        // Check the metadata key.
        final int metadataId = parcel.readInt();

        // Store the record offset which points to the type
        // field so we can later on read/unmarshall the record
        // payload.
        if (mKeyToPosMap.containsKey(metadataId)) {
            Log.e(TAG, "Duplicate metadata ID found");
            error = true;
            break;
        }

        mKeyToPosMap.put(metadataId, parcel.dataPosition());

        // Check the metadata type.
        final int metadataType = parcel.readInt();
        if (metadataType <= 0 || metadataType > LAST_TYPE) {
            Log.e(TAG, "Invalid metadata type " + metadataType);
            error = true;
            break;
        }

        // Skip to the next one.
        parcel.setDataPosition(start + size);
        bytesLeft -= size;
        ++recCount;
    }

    if (0 != bytesLeft || error) {
        Log.e(TAG, "Ran out of data or error on record " + recCount);
        mKeyToPosMap.clear();
        return false;
    } else {
        return true;
    }
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:77,代码来源:MediaMetadata.java


注:本文中的android.os.Parcel.dataPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。