Code example for Parcel

Methods: dataPositionsetDataPositionwriteBooleanArraywriteString

0
 
    /** {@inheritDoc} */ 
    @Override 
    public void writeToParcel(Parcel dest, int flags) {
        boolean[] validDataList = new boolean[MemberData.values().length];
        int validDataPos = dest.dataPosition();
        dest.writeBooleanArray(validDataList); // Placeholder for real array.
 
        if (mValue != null) {
            validDataList[MemberData.VALUE.ordinal()] = true;
            boolean[] b = new boolean[1];
            b[0] = mValue;
            dest.writeBooleanArray(b);
        } 
        if (mCapability != null) {
            validDataList[MemberData.CAPABILITY.ordinal()] = true;
            dest.writeString(mCapability.name());
        } 
        if (mDescription != null) {
            validDataList[MemberData.DESCRIPTION.ordinal()] = true;
            dest.writeString(mDescription);
        } 
        if (mName != null) {
            validDataList[MemberData.NAME.ordinal()] = true;
            dest.writeString(mName);
        } 
 
        int currentPos = dest.dataPosition();
        dest.setDataPosition(validDataPos);
        dest.writeBooleanArray(validDataList); // Real array.
        dest.setDataPosition(currentPos);
 
    } 
 
    /** 
     * Read IdentityCapability item from Parcel. 
Experience pair programming with AI  Get Codota for Java