Java Code Examples for android.os.Parcelable#describeContents()

The following examples show how to use android.os.Parcelable#describeContents() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParcelableModelsTest.java    From spotify-web-api-android with MIT License 6 votes vote down vote up
@Test
public void allParcelables() throws IllegalAccessException, InstantiationException, NoSuchFieldException {

    ModelPopulator populator = new ModelPopulator("CREATOR", "$jacocoData");

    for (Class<? extends Parcelable> modelClass : getModelClasses()) {

        Parcelable instance = populator.populateWithRandomValues(modelClass);

        testSingleParcelable(instance);
        testParcelableArray(instance);

        /* Trick to increase code coverage */
        instance.describeContents();
        ((Parcelable.Creator<?>) modelClass.getField("CREATOR").get(null)).newArray(13);
    }
}
 
Example 2
Source File: ParcelableTester.java    From mv2m with Apache License 2.0 5 votes vote down vote up
private static void writeParcelable(LinkedList<Object> parcelData, Parcelable parcelable, Parcel parcel1) {
    if (parcelable == null) {
        parcelData.add(null);
    } else {
        parcelable.describeContents();
        parcelData.add(parcelable.getClass());
        parcelable.writeToParcel(parcel1, 0);
    }
}