read Type ArrayList from Parcel - Android android.os

Android examples for android.os:Parcel

Description

read Type ArrayList from Parcel

Demo Code


//package com.java2s;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;

public class Main {
    public static <T extends Parcelable> ArrayList<T> readTypeArrayList(
            Parcel source, Parcelable.Creator<T> creator) {
        boolean isNull = readBoolean(source);
        if (isNull) {
            return null;
        } else {/*from w w w .j  av  a 2s .c  o m*/
            return source.createTypedArrayList(creator);
        }
    }

    public static boolean readBoolean(Parcel source) {
        return source.readInt() == 1;
    }
}

Related Tutorials