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

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

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

Parcel.writeDouble介绍

[英]Write a double precision floating point value into the parcel at the current dataPosition(), growing dataCapacity() if needed.
[中]将双精度浮点值写入当前dataPosition()处的地块,必要时增加dataCapacity()。

代码示例

代码示例来源:origin: johncarl81/parceler

@Override
  public void nullSafeToParcel(Double input, Parcel parcel) {
    parcel.writeDouble(input);
  }
};

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

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeDouble(latitude);
  dest.writeDouble(longitude);
  dest.writeDouble(altitude);
  dest.writeFloat(accuracy);
  dest.writeFloat(speed);
  dest.writeFloat(bearing);
}

代码示例来源:origin: anjlab/android-inapp-billing-v3

@Override
public void writeToParcel(Parcel dest, int flags)
{
  dest.writeString(this.productId);
  dest.writeString(this.title);
  dest.writeString(this.description);
  dest.writeByte(isSubscription ? (byte) 1 : (byte) 0);
  dest.writeString(this.currency);
  dest.writeDouble(this.priceValue);
  dest.writeLong(this.priceLong);
  dest.writeString(this.priceText);
  dest.writeString(this.subscriptionPeriod);
  dest.writeString(this.subscriptionFreeTrialPeriod);
  dest.writeByte(this.haveTrialPeriod ? (byte) 1 : (byte) 0);
  dest.writeDouble(this.introductoryPriceValue);
  dest.writeLong(this.introductoryPriceLong);
  dest.writeString(this.introductoryPriceText);
  dest.writeString(this.introductoryPricePeriod);
  dest.writeByte(this.haveIntroductoryPeriod ? (byte) 1 : (byte) 0);
  dest.writeInt(this.introductoryPriceCycles);
}

代码示例来源:origin: jaydenxiao2016/AndroidFire

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeString(this.address);
  dest.writeString(this.appointUserNickname);
  dest.writeString(this.appointUserid);
  dest.writeString(this.content);
  dest.writeLong(this.createTime);
  dest.writeInt(this.goodjobCount);
  dest.writeString(this.id);
  dest.writeString(this.isvalid);
  dest.writeDouble(this.latitude);
  dest.writeDouble(this.longitude);
  dest.writeString(this.pictures);
  dest.writeInt(this.replyCount);
  dest.writeInt(this.type);
  dest.writeString(this.icon);
  dest.writeString(this.userId);
  dest.writeString(this.nickName);
  dest.writeTypedList(goodjobs);
  dest.writeTypedList(replys);
  dest.writeString(this.linkImg);
  dest.writeString(this.linkTitle);
  dest.writeInt(this.takeTimes);
}

代码示例来源:origin: AltBeacon/android-beacon-library

out.writeString(identifier == null ? null : identifier.toString());
out.writeDouble(getDistance());
out.writeInt(mRssi);
out.writeInt(mTxPower);

代码示例来源:origin: jaydenxiao2016/AndroidFire

dest.writeInt(this.totalPage);
dest.writeString(this.clevel);
dest.writeDouble(this.latitude);
dest.writeDouble(this.longitude);
dest.writeInt(this.totalStars);
dest.writeInt(this.totalTimes);

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

dest.writeDouble(betrag);
dest.writeDouble(betrag_effected);
dest.writeInt(taxType);
dest.writeInt(tax);

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

@Test
public void testDataAvail() {
 parcel.writeInt(1);
 parcel.writeFloat(5);
 parcel.writeDouble(6);
 parcel.setDataPosition(4);
 assertThat(parcel.dataAvail()).isEqualTo(12);
}

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

@Test
public void testSetDataPositionIntoMiddleOfParcel() {
 parcel.writeInt(1);
 parcel.writeFloat(5);
 parcel.writeDouble(6);
 parcel.setDataPosition(4);
 assertThat(parcel.readFloat()).isEqualTo(5.0f);
}

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

@Test
public void testDataSizeAfterSomeWrites() {
 parcel.writeInt(1);
 assertThat(parcel.dataSize()).isEqualTo(4);
 parcel.writeFloat(5);
 assertThat(parcel.dataSize()).isEqualTo(8);
 parcel.writeDouble(37);
 assertThat(parcel.dataSize()).isEqualTo(16);
}

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

@Test
public void testDataPositionAfterSomeReads() {
 parcel.writeInt(1);
 parcel.writeFloat(5);
 parcel.writeDouble(37);
 parcel.setDataPosition(0);
 parcel.readInt();
 assertThat(parcel.dataPosition()).isEqualTo(4);
 parcel.readFloat();
 assertThat(parcel.dataPosition()).isEqualTo(8);
 parcel.readDouble();
 assertThat(parcel.dataPosition()).isEqualTo(16);
}

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

@Test
public void testZeroCanBeCasted_8ByteTypesCanBeReadAs4Bytes() {
 parcel.writeLong(0);
 parcel.writeDouble(0.0);
 parcel.writeLong(0);
 assertThat(parcel.dataSize()).named("total size").isEqualTo(24);
 parcel.setDataPosition(0);
 assertThat(parcel.readInt()).isEqualTo(0);
 assertThat(parcel.readFloat()).isEqualTo(0.0f);
 assertThat(parcel.createByteArray()).isEqualTo(new byte[0]);
 assertThat(parcel.dataPosition()).isEqualTo(12);
 assertThat(parcel.readInt()).isEqualTo(0);
 assertThat(parcel.readFloat()).isEqualTo(0.0f);
 assertThat(parcel.createByteArray()).isEqualTo(new byte[0]);
 assertThat(parcel.dataPosition()).isEqualTo(24);
}

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

@Test
public void testDataPositionAfterSomeWrites() {
 parcel.writeInt(1);
 assertThat(parcel.dataPosition()).isEqualTo(4);
 parcel.writeFloat(5);
 assertThat(parcel.dataPosition()).isEqualTo(8);
 parcel.writeDouble(37);
 assertThat(parcel.dataPosition()).isEqualTo(16);
 parcel.writeStrongBinder(new Binder()); // 20 bytes
 assertThat(parcel.dataPosition()).isEqualTo(36);
}

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

@Test
public void testZeroCanBeCasted_overwrittenValuesAreOk() {
 parcel.writeByteArray(new byte[8]);
 assertThat(parcel.dataPosition()).isEqualTo(12);
 parcel.writeDouble(0.0);
 assertThat(parcel.dataPosition()).isEqualTo(20);
 parcel.writeLong(0);
 parcel.setDataPosition(8);
 parcel.writeInt(0); // Overwrite the second half of the byte array.
 parcel.setDataPosition(16);
 parcel.writeLong(0); // Overwrite the second half of the double and first half of the long.
 parcel.setDataPosition(20);
 parcel.writeInt(0); // And overwrite the second half of *that* with an int.
 assertThat(parcel.dataSize()).named("total size").isEqualTo(28);
 parcel.setDataPosition(0);
 assertThat(parcel.readInt()).named("initial array length").isEqualTo(8);
 // After this, we are reading all zeroes.  If we just read them as regular old types, it would
 // yield errors, but the special-casing for zeroes addresses this.  Make sure each data type
 // consumes the correct number of bytes.
 assertThat(parcel.readLong()).isEqualTo(0L);
 assertThat(parcel.dataPosition()).isEqualTo(12);
 assertThat(parcel.readString()).isEqualTo("");
 assertThat(parcel.dataPosition()).isEqualTo(20);
 assertThat(parcel.createByteArray()).isEqualTo(new byte[0]);
 assertThat(parcel.dataPosition()).isEqualTo(24);
 assertThat(parcel.readInt()).isEqualTo(0);
 assertThat(parcel.dataPosition()).isEqualTo(28);
}

代码示例来源:origin: parse-community/Parse-SDK-Android

void writeToParcel(Parcel dest, ParseParcelEncoder encoder) {
    dest.writeDouble(latitude);
    dest.writeDouble(longitude);
  }
}

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

@Test
public void testMarshallAndUnmarshall() {
 parcel.writeInt(1);
 parcel.writeString("hello");
 parcel.writeDouble(25.0);
 parcel.writeFloat(1.25f);
 parcel.writeByte((byte) 0xAF);
 int oldSize = parcel.dataSize();
 parcel.setDataPosition(7);
 byte[] rawBytes = parcel.marshall();
 assertWithMessage("data position preserved").that(parcel.dataPosition()).isEqualTo(7);
 Parcel parcel2 = Parcel.obtain();
 assertInvariants(parcel2);
 parcel2.unmarshall(rawBytes, 0, rawBytes.length);
 assertThat(parcel2.dataPosition()).isEqualTo(parcel2.dataSize());
 parcel2.setDataPosition(0);
 assertThat(parcel2.dataSize()).isEqualTo(oldSize);
 assertThat(parcel2.readInt()).isEqualTo(1);
 assertThat(parcel2.readString()).isEqualTo("hello");
 assertThat(parcel2.readDouble()).isEqualTo(25.0);
 assertThat(parcel2.readFloat()).isEqualTo(1.25f);
 assertThat(parcel2.readByte()).isEqualTo((byte) 0xAF);
}

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

@Test
public void testReadWriteNumbers() {
 parcel.writeInt(Integer.MIN_VALUE);
 assertThat(parcel.dataSize()).isEqualTo(4);
 parcel.writeLong(Long.MAX_VALUE);
 assertThat(parcel.dataSize()).isEqualTo(12);
 double d = 3.14159;
 parcel.writeDouble(d);
 assertThat(parcel.dataSize()).isEqualTo(20);
 float f = -6.022e23f;
 parcel.writeFloat(f);
 assertThat(parcel.dataSize()).isEqualTo(24);
 assertInvariants();
 parcel.setDataPosition(0);
 assertThat(parcel.readInt()).isEqualTo(Integer.MIN_VALUE);
 assertThat(parcel.dataPosition()).isEqualTo(4);
 assertThat(parcel.readLong()).isEqualTo(Long.MAX_VALUE);
 assertThat(parcel.dataPosition()).isEqualTo(12);
 assertThat(parcel.readDouble()).isEqualTo(d);
 assertThat(parcel.dataPosition()).isEqualTo(20);
 assertThat(parcel.readFloat()).isEqualTo(f);
 assertThat(parcel.dataPosition()).isEqualTo(24);
 assertWithMessage("read past end is valid").that(parcel.readInt()).isEqualTo(0);
 assertThat(parcel.dataPosition()).isEqualTo(24);
 assertInvariants();
}

代码示例来源:origin: guoxiaoxing/phoenix

dest.writeInt(this.height);
dest.writeLong(this.size);
dest.writeDouble(this.latitude);
dest.writeDouble(this.longitude);
dest.writeByte(this.isUploaded ? (byte) 1 : (byte) 0);
dest.writeString(this.onlinePath);

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

public void writeToParcel(Parcel dest, int flags) {
  dest.writeString(type);
  dest.writeString(numberPlate);
  dest.writeString(brand);
  dest.writeDouble(pricePerHour);
  dest.writeDouble(pricePerKm);
  dest.writeString(objectId);
  dest.writeInt(photo.length());
  dest.writeByteArray(photo);
}


public void readFromParcel(Parcel in){
  this.type = in.readString();
  this.numberPlate = in.readString();
  this.brand = in.readString();
  this.pricePerHour = in.readDouble();
  this.pricePerKm = in.readDouble();
  this.objectId = in.readString();
  this.photo = new byte[in.readInt()];
  in.readByteArray(this.photo);
}

代码示例来源:origin: limpoxe/Android-Plugin-Framework

/**
   * Demonstrates some basic types that you can use as parameters
   * and return values in AIDL.
   */
@Override public void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat, double aDouble, String aString) throws android.os.RemoteException
{
android.os.Parcel _data = android.os.Parcel.obtain();
android.os.Parcel _reply = android.os.Parcel.obtain();
try {
_data.writeInterfaceToken(DESCRIPTOR);
_data.writeInt(anInt);
_data.writeLong(aLong);
_data.writeInt(((aBoolean)?(1):(0)));
_data.writeFloat(aFloat);
_data.writeDouble(aDouble);
_data.writeString(aString);
mRemote.transact(Stub.TRANSACTION_basicTypes, _data, _reply, 0);
_reply.readException();
}
finally {
_reply.recycle();
_data.recycle();
}
}
}

相关文章

Parcel类方法