android.os.Parcel.writeInt()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(293)

本文整理了Java中android.os.Parcel.writeInt()方法的一些代码示例,展示了Parcel.writeInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parcel.writeInt()方法的具体详情如下:
包路径:android.os.Parcel
类名称:Parcel
方法名:writeInt

Parcel.writeInt介绍

[英]Write an integer value into the parcel at the current dataPosition(), growing dataCapacity() if needed.
[中]在当前dataPosition()处向包裹中写入一个整数值,必要时增加dataCapacity()。

代码示例

代码示例来源:origin: airbnb/lottie-android

@Override
public void writeToParcel(Parcel out, int flags) {
 super.writeToParcel(out, flags);
 out.writeString(animationName);
 out.writeFloat(progress);
 out.writeInt(isAnimating ? 1 : 0);
 out.writeString(imageAssetsFolder);
 out.writeInt(repeatMode);
 out.writeInt(repeatCount);
}

代码示例来源:origin: stackoverflow.com

out.writeInt(mData);
mData = in.readInt();

代码示例来源:origin: smuyyh/BookReader

@Override
  public void writeToParcel(Parcel dest, int flags) {
    super.writeToParcel(dest, flags);
    tagCount = tags.length;
    dest.writeInt(tagCount);
    dest.writeStringArray(tags);
    dest.writeInt(checkedPosition);
    dest.writeString(input);
  }
}

代码示例来源:origin: stackoverflow.com

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeString(name);
  dest.writeInt(numOfSeason);
  dest.writeInt(numOfEpisode);
}

private void readFromParcel(Parcel in) {
  name = in.readString();
  numOfSeason = in.readInt();
  numOfEpisode = in.readInt();
}

代码示例来源:origin: android-hacker/VirtualXposed

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeInt(this.vuid);
  dest.writeString(this.packageName);
  dest.writeInt(this.clientJobId);
}

代码示例来源:origin: stackoverflow.com

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeParcelable(otherClass, flags);
  dest.writeString(name);
  dest.writeInt(id);
}

private MyClass(Parcel in) {
  otherClass = (OtherClass) in.readParcelable(OtherClass.class.getClassLoader());
  name = in.readString();
  id = in.readInt();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testWriteThenReadIsOkIfNotAtEnd() {
 parcel.writeInt(1);
 parcel.writeInt(2);
 parcel.writeInt(3);
 parcel.writeInt(4);
 parcel.setDataPosition(0);
 parcel.writeInt(5);
 assertThat(parcel.readInt()).isEqualTo(2);
 assertThat(parcel.readInt()).isEqualTo(3);
 assertThat(parcel.readInt()).isEqualTo(4);
 // This should succeed: while this is weird, the caller didn't clearly forget to reset the data
 // position, and is reading past the end of the parcel in a normal way.
 assertThat(parcel.readInt()).isEqualTo(0);
}

代码示例来源: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: 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: stackoverflow.com

public void writeToParcel(Parcel out, int flags){
 out.writeInt(map.size());
 for(Map.Entry<String,String> entry : map.entrySet()){
  out.writeString(entry.getKey());
  out.writeString(entry.getValue());
 }
}

private MyParcelable(Parcel in){
 //initialize your map before
 int size = in.readInt();
 for(int i = 0; i < size; i++){
  String key = in.readString();
  String value = in.readString();
  map.put(key,value);
 }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testReadWithoutRewinding() {
 parcel.writeInt(123);
 try {
  parcel.readInt();
  fail("should have thrown");
 } catch (UnreliableBehaviorError e) {
  assertThat(e).hasMessage("Did you forget to setDataPosition(0) before reading the parcel?");
 }
}

代码示例来源:origin: bluelinelabs/Conductor

@Override
public void writeToParcel(Parcel out, int flags) {
  out.writeString(instanceId);
  out.writeStringArray(permissions);
  out.writeInt(requestCode);
}

代码示例来源:origin: google/ExoPlayer

@Override
public void writeToParcel(Parcel dest, int flags) {
 dest.writeString(key);
 dest.writeInt(value.length);
 dest.writeByteArray(value);
 dest.writeInt(localeIndicator);
 dest.writeInt(typeIndicator);
}

代码示例来源:origin: stackoverflow.com

public void writeToParcel(Parcel out, int flags) {
  out.writeString(_mac);
  out.writeString(_pan);
  out.writeInt(_band);
  out.writeSerializable(_lqis);
  out.writeTypedList(_devices);
}

private ZigBeeNetwork(Parcel in) {
  _mac = in.readString();
  _pan = in.readString();
  _band = in.readInt();
  _lqis = (ArrayList<Integer>) in.readSerializable();
  in.readTypedList(_devices, ZigBeeDev.CREATOR);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testReadWriteMultipleInts() {
 for (int i = 0; i < 10; ++i) {
  parcel.writeInt(i);
 }
 parcel.setDataPosition(0);
 for (int i = 0; i < 10; ++i) {
  assertThat(parcel.readInt()).isEqualTo(i);
 }
 // now try to read past the number of items written and see what happens
 assertThat(parcel.readInt()).isEqualTo(0);
}

代码示例来源:origin: android-hacker/VirtualXposed

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeInt(this.mode);
  dest.writeInt(this.installFlags);
  dest.writeInt(this.installLocation);
  dest.writeLong(this.sizeBytes);
  dest.writeString(this.appPackageName);
  dest.writeParcelable(this.appIcon, flags);
  dest.writeString(this.appLabel);
  dest.writeLong(this.appIconLastModified);
  dest.writeParcelable(this.originatingUri, flags);
  dest.writeParcelable(this.referrerUri, flags);
  dest.writeString(this.abiOverride);
  dest.writeString(this.volumeUuid);
  dest.writeStringArray(this.grantedRuntimePermissions);
}

代码示例来源:origin: android-hacker/VirtualXposed

@Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeParcelable(this.filter, flags);
    dest.writeByte(this.hasDefault ? (byte) 1 : (byte) 0);
    dest.writeInt(this.labelRes);
    dest.writeString(this.nonLocalizedLabel);
    dest.writeInt(this.icon);
    dest.writeInt(this.logo);
    dest.writeInt(this.banner);
  }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testReadWriteStringInt() {
 for (int i = 0; i < 10; ++i) {
  parcel.writeString(Integer.toString(i));
  parcel.writeInt(i);
 }
 parcel.setDataPosition(0);
 for (int i = 0; i < 10; ++i) {
  assertThat(parcel.readString()).isEqualTo(Integer.toString(i));
  assertThat(parcel.readInt()).isEqualTo(i);
 }
 // now try to read past the number of items written and see what happens
 assertThat(parcel.readString()).isNull();
 assertThat(parcel.readInt()).isEqualTo(0);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testReadWriteSingleInt() {
 int val = 5;
 parcel.writeInt(val);
 parcel.setDataPosition(0);
 assertThat(parcel.readInt()).isEqualTo(val);
}

代码示例来源:origin: seven332/EhViewer

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeString(this.imageUrl);
  dest.writeString(this.pageUrl);
  dest.writeInt(this.position);
  dest.writeInt(this.offsetX);
  dest.writeInt(this.offsetY);
  dest.writeInt(this.clipWidth);
  dest.writeInt(this.clipHeight);
}

相关文章

Parcel类方法