/** * Creates a new point instance from a {@link Parcel} source. This is used when unparceling a * ParsePolygon. Subclasses that need Parcelable behavior should provide their own * {@link android.os.Parcelable.Creator} and override this constructor. * * @param source The recovered parcel. */ protected ParsePolygon(Parcel source) { this(source, ParseParcelDecoder.get()); }
/** * Creates a new point instance from a {@link Parcel} source. This is used when unparceling a * ParseGeoPoint. Subclasses that need Parcelable behavior should provide their own * {@link android.os.Parcelable.Creator} and override this constructor. * * @param source The recovered parcel. */ protected ParseGeoPoint(Parcel source) { this(source, ParseParcelDecoder.get()); }
/** * Creates a new file instance from a {@link Parcel} source. This is used when unparceling * a non-dirty ParseFile. Subclasses that need Parcelable behavior should provide their own * {@link android.os.Parcelable.Creator} and override this constructor. * * @param source the source Parcel */ protected ParseFile(Parcel source) { this(source, ParseParcelDecoder.get()); }
@Override public ParsePolygon createFromParcel(Parcel source) { return new ParsePolygon(source, ParseParcelDecoder.get()); }
@Override public ParseGeoPoint createFromParcel(Parcel source) { return new ParseGeoPoint(source, ParseParcelDecoder.get()); }
@Test public void testParcelable() { long updatedAt = System.currentTimeMillis(); long createdAt = updatedAt + 10; ParseObject.State state = new ParseObject.State.Builder("TestObject") .objectId("fake") .createdAt(new Date(createdAt)) .updatedAt(new Date(updatedAt)) .isComplete(true) .put("foo", "bar") .put("baz", "qux") .availableKeys(Arrays.asList("safe", "keys")) .build(); Parcel parcel = Parcel.obtain(); state.writeToParcel(parcel, ParseParcelEncoder.get()); parcel.setDataPosition(0); ParseObject.State copy = ParseObject.State.createFromParcel(parcel, ParseParcelDecoder.get()); assertEquals(state.className(), copy.className()); assertEquals(state.objectId(), copy.objectId()); assertEquals(state.createdAt(), copy.createdAt()); assertEquals(state.updatedAt(), copy.updatedAt()); assertEquals(state.isComplete(), copy.isComplete()); assertEquals(state.keySet().size(), copy.keySet().size()); assertEquals(state.get("foo"), copy.get("foo")); assertEquals(state.get("baz"), copy.get("baz")); assertEquals(state.availableKeys().size(), copy.availableKeys().size()); assertTrue(state.availableKeys().containsAll(copy.availableKeys())); assertTrue(copy.availableKeys().containsAll(state.availableKeys())); }