本文整理了Java中android.os.Parcel.writeParcelable()
方法的一些代码示例,展示了Parcel.writeParcelable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parcel.writeParcelable()
方法的具体详情如下:
包路径:android.os.Parcel
类名称:Parcel
方法名:writeParcelable
[英]Flatten the name of the class of the Parcelable and its contents into the parcel.
[中]将包裹类别的名称及其内容展平到包裹中。
代码示例来源:origin: stackoverflow.com
class B implements Parcelable{
//lets assume you have A as a data member
A obj;
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(obj , flags);
}
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(length);
for (int i = 0; i < length; i++) {
dest.writeParcelable(formats[i], 0);
}
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(entries.length);
for (Entry entry : entries) {
dest.writeParcelable(entry, 0);
}
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(length);
for (int i = 0; i < length; i++) {
dest.writeParcelable(trackGroups[i], 0);
}
}
代码示例来源:origin: pockethub/PocketHub
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(repository, flags);
dest.writeTypedList(labels);
dest.writeParcelable(milestone, flags);
dest.writeParcelable(assignee, flags);
dest.writeByte((byte) (open ? 1 : 0));
dest.writeString(direction);
dest.writeString(sortType);
}
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(chapterId);
dest.writeInt(startTimeMs);
dest.writeInt(endTimeMs);
dest.writeLong(startOffset);
dest.writeLong(endOffset);
dest.writeInt(subFrames.length);
for (Id3Frame subFrame : subFrames) {
dest.writeParcelable(subFrame, 0);
}
}
代码示例来源:origin: vondear/RxTool
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeInt(facing);
out.writeParcelable(ratio, 0);
out.writeByte((byte) (autoFocus ? 1 : 0));
out.writeInt(flash);
}
代码示例来源:origin: zhihu/Matisse
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(mimeType);
dest.writeParcelable(uri, 0);
dest.writeLong(size);
dest.writeLong(duration);
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(elementId);
dest.writeByte((byte) (isRoot ? 1 : 0));
dest.writeByte((byte) (isOrdered ? 1 : 0));
dest.writeStringArray(children);
dest.writeInt(subFrames.length);
for (Id3Frame subFrame : subFrames) {
dest.writeParcelable(subFrame, 0);
}
}
代码示例来源:origin: florent37/MaterialViewPager
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeParcelable(this.settings, flags);
out.writeFloat(this.yOffset);
}
}
代码示例来源:origin: johncarl81/parceler
@Override
public void itemToParcel(Object input, Parcel parcel) {
parcel.writeParcelable(Parcels.wrap(input), 0);
}
};
代码示例来源:origin: johncarl81/parceler
@Override
public void itemToParcel(Object input, Parcel parcel) {
parcel.writeParcelable(Parcels.wrap(input), 0);
}
};
代码示例来源:origin: johncarl81/parceler
@Override
public void itemToParcel(Object input, Parcel parcel) {
parcel.writeParcelable(Parcels.wrap(input), 0);
}
};
代码示例来源:origin: PhilJay/MPAndroidChart
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeFloat(this.x);
dest.writeFloat(this.getY());
if (getData() != null) {
if (getData() instanceof Parcelable) {
dest.writeInt(1);
dest.writeParcelable((Parcelable) this.getData(), flags);
} else {
throw new ParcelFormatException("Cannot parcel an Entry with non-parcelable data");
}
} else {
dest.writeInt(0);
}
}
代码示例来源:origin: robolectric/robolectric
@Implementation
protected void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(getPhoneAccountHandle(), flags);
dest.writeString(getPrefix());
dest.writeBundle(getFields());
dest.writeString(getMessageBody());
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testParcelableWithBase() throws Exception {
TestParcelableImpl normal = new TestParcelableImpl(23);
parcel.writeParcelable(normal, 0);
parcel.setDataPosition(0);
TestParcelableImpl rehydrated = parcel.readParcelable(TestParcelableImpl.class.getClassLoader());
assertEquals(normal.contents, rehydrated.contents);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testParcelableWithPublicClass() throws Exception {
TestParcelable normal = new TestParcelable(23);
parcel.writeParcelable(normal, 0);
parcel.setDataPosition(0);
TestParcelable rehydrated = parcel.readParcelable(TestParcelable.class.getClassLoader());
assertEquals(normal.contents, rehydrated.contents);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testParcelableWithPackageProtected() throws Exception {
TestParcelablePackage normal = new TestParcelablePackage(23);
parcel.writeParcelable(normal, 0);
parcel.setDataPosition(0);
TestParcelablePackage rehydrated = parcel.readParcelable(TestParcelablePackage.class.getClassLoader());
assertEquals(normal.contents, rehydrated.contents);
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(minSdk = Build.VERSION_CODES.O_MR1)
public void writeToParcel_shouldNotCrash() throws Exception {
try (SharedMemory sharedMemory = SharedMemory.create("foo", 4)) {
ByteBuffer fooBuf = sharedMemory.mapReadWrite();
fooBuf.putInt(1234);
Parcel parcel = Parcel.obtain();
parcel.writeParcelable(sharedMemory, 0);
}
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testReadWriteParcelable() {
Account a1 = new Account("name", "type");
parcel.writeParcelable(a1, 0);
parcel.setDataPosition(0);
Account a2 = parcel.readParcelable(Account.class.getClassLoader());
assertEquals(a1, a2);
}
内容来源于网络,如有侵权,请联系作者删除!