本文整理了Java中android.os.Parcel.appendFrom()
方法的一些代码示例,展示了Parcel.appendFrom()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parcel.appendFrom()
方法的具体详情如下:
包路径:android.os.Parcel
类名称:Parcel
方法名:appendFrom
暂无
代码示例来源:origin: robolectric/robolectric
@Test
public void testAppendFrom() {
// Write a mixture of things, and overwrite something.
parcel.writeInt(1);
parcel.writeInt(2);
parcel.writeInt(3);
parcel.writeInt(4);
// Create a parcel2 that sandwiches parcel1 with happy birthday.
Parcel parcel2 = Parcel.obtain();
parcel2.writeString("happy");
parcel2.appendFrom(parcel, 4, 8);
assertInvariants(parcel);
assertInvariants(parcel2);
parcel2.writeString("birthday");
assertInvariants(parcel);
parcel2.setDataPosition(0);
assertThat(parcel2.readString()).isEqualTo("happy");
assertThat(parcel2.readInt()).isEqualTo(2);
assertThat(parcel2.readInt()).isEqualTo(3);
assertThat(parcel2.readString()).isEqualTo("birthday");
assertThat(parcel2.dataAvail()).isEqualTo(0);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
private static Parcel copyParcel(Parcel data) {
Parcel clone = Parcel.obtain();
clone.appendFrom(data, 0, data.dataSize());
clone.setDataPosition(0);
return clone;
}
代码示例来源:origin: stackoverflow.com
void writeToParcelInner(Parcel parcel, int flags) {
if (mParcelledData != null) {
if (mParcelledData == EMPTY_PARCEL) {
parcel.writeInt(0);
} else {
int length = mParcelledData.dataSize();
parcel.writeInt(length);
parcel.writeInt(BUNDLE_MAGIC);
parcel.appendFrom(mParcelledData, 0, length);
}
} else {
.......... extra code chopped out for illustration purposes
}
}
代码示例来源:origin: stackoverflow.com
int magic = parcel.readInt();
if (magic != BUNDLE_MAGIC) {
//noinspection ThrowableInstanceNeverThrown
throw new IllegalStateException("Bad magic number for Bundle: 0x"
+ Integer.toHexString(magic));
}
int offset = parcel.dataPosition();
parcel.setDataPosition(offset + length);
Parcel p = Parcel.obtain();
p.setDataPosition(0);
p.appendFrom(parcel, offset, length);
p.setDataPosition(0);
mParcelledData = p;
代码示例来源:origin: ManbangGroup/Phantom
originParcel.appendFrom(intentParcel, intentParcelOffset + intSize, intentParcelLen - intSize);
originParcel.setDataPosition(0);
内容来源于网络,如有侵权,请联系作者删除!