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

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

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

Parcel.readLongArray介绍

暂无

代码示例

代码示例来源:origin: googlesamples/android-testing

private LogHistory(Parcel in) {
    // First, read the size of the arrays that contain the data.
    int length = in.readInt();

    // Create the arrays to store the data.
    String[] texts = new String[length];
    long[] timestamps = new long[length];

    // Read the arrays in a specific order.
    in.readStringArray(texts);
    in.readLongArray(timestamps);

    // The lengths of both arrays should match or the data is corrupted.
    if (texts.length != timestamps.length) {
      throw new IllegalStateException("Error reading from saved state.");
    }

    // Reset the data container and update the data.
    mData.clear();
    for (int i = 0; i < texts.length; i++) {
      Pair<String, Long> pair = new Pair<>(texts[i], timestamps[i]);
      mData.add(pair);
    }
  }
}

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

@Test
public void testReadWriteLongArray() throws Exception {
 final long[] longs = { 1, 2 };
 parcel.writeLongArray(longs);
 parcel.setDataPosition(0);
 final long[] longs2 = new long[longs.length];
 parcel.readLongArray(longs2);
 assertTrue(Arrays.equals(longs, longs2));
}

代码示例来源:origin: codezjx/AndLinker

@Override
public void readFromParcel(Parcel in, long[] val) {
  in.readLongArray(val);
}

代码示例来源:origin: com.albedinsky.android/dialogs-collection

/**
 * Called from {@link #CREATOR} to create an instance of SavedState form the given parcel
 * <var>source</var>.
 *
 * @param source Parcel with data for the new instance.
 */
protected SavedState(@NonNull Parcel source) {
  super(source);
  this.selection = new long[source.readInt()];
  source.readLongArray(selection);
}

代码示例来源:origin: com.albedinsky.android.support/support-dialogs-collection

/**
 * Called from {@link #CREATOR} to create an instance of SavedState form the given parcel
 * <var>source</var>.
 *
 * @param source Parcel with data for the new instance.
 */
protected SavedState(@NonNull Parcel source) {
  super(source);
  this.selection = new long[source.readInt()];
  source.readLongArray(selection);
}

代码示例来源:origin: com.albedinsky.android/dialogs

/**
 * Called from {@link #CREATOR} to create an instance of SavedState form the given parcel
 * <var>source</var>.
 *
 * @param source Parcel with data for the new instance.
 */
protected SavedState(@NonNull Parcel source) {
  super(source);
  this.selection = new long[source.readInt()];
  source.readLongArray(selection);
}

代码示例来源:origin: com.albedinsky.android.support/support-dialogs

/**
 * Called from {@link #CREATOR} to create an instance of SavedState form the given parcel
 * <var>source</var>.
 *
 * @param source Parcel with data for the new instance.
 */
protected SavedState(@NonNull Parcel source) {
  super(source);
  this.selection = new long[source.readInt()];
  source.readLongArray(selection);
}

代码示例来源:origin: com.albedinsky.android.support/support-dialogs-collection

/**
 * Called form {@link #CREATOR} to create an instance of SelectionOptions form the given parcel
 * <var>source</var>.
 *
 * @param source Parcel with data for the new instance.
 */
protected SelectionOptions(@NonNull Parcel source) {
  super(source);
  this.selectionMode = source.readInt();
  this.emptySelectionAllowed = source.readInt() == 1;
  //noinspection unchecked
  this.items = source.readArrayList(DialogsConfig.class.getClassLoader());
  if (source.readInt() >= 0) {
    selection = new long[source.readInt()];
    source.readLongArray(selection);
  }
}

代码示例来源:origin: com.albedinsky.android/dialogs-collection

/**
 * Called form {@link #CREATOR} to create an instance of SelectionOptions form the given parcel
 * <var>source</var>.
 *
 * @param source Parcel with data for the new instance.
 */
protected SelectionOptions(@NonNull Parcel source) {
  super(source);
  this.selectionMode = source.readInt();
  this.emptySelectionAllowed = source.readInt() == 1;
  //noinspection unchecked
  this.items = source.readArrayList(DialogsConfig.class.getClassLoader());
  if (source.readInt() >= 0) {
    selection = new long[source.readInt()];
    source.readLongArray(selection);
  }
}

代码示例来源:origin: com.albedinsky.android/dialogs

/**
 * Called form {@link #CREATOR} to create an instance of SelectionOptions form the given parcel
 * <var>source</var>.
 *
 * @param source Parcel with data for the new instance.
 */
protected SelectionOptions(@NonNull Parcel source) {
  super(source);
  this.selectionMode = source.readInt();
  this.emptySelectionAllowed = source.readInt() == 1;
  //noinspection unchecked
  this.items = source.readArrayList(DialogsConfig.class.getClassLoader());
  if (source.readInt() >= 0) {
    selection = new long[source.readInt()];
    source.readLongArray(selection);
  }
}

代码示例来源:origin: com.albedinsky.android.support/support-dialogs

/**
 * Called form {@link #CREATOR} to create an instance of SelectionOptions form the given parcel
 * <var>source</var>.
 *
 * @param source Parcel with data for the new instance.
 */
protected SelectionOptions(@NonNull Parcel source) {
  super(source);
  this.selectionMode = source.readInt();
  this.emptySelectionAllowed = source.readInt() == 1;
  //noinspection unchecked
  this.items = source.readArrayList(DialogsConfig.class.getClassLoader());
  if (source.readInt() >= 0) {
    selection = new long[source.readInt()];
    source.readLongArray(selection);
  }
}

相关文章

Parcel类方法