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

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

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

Parcel.writeParcelableArray介绍

[英]Write a heterogeneous array of Parcelable objects into the Parcel. Each object in the array is written along with its class name, so that the correct class can later be instantiated. As a result, this has significantly more overhead than #writeTypedArray, but will correctly handle an array containing more than one type of object.
[中]将可包裹对象的异构数组写入包裹。数组中的每个对象都会与其类名一起写入,以便以后可以实例化正确的类。因此,这比#WriteTypeArray的开销要大得多,但可以正确处理包含多种类型对象的数组。

代码示例

代码示例来源:origin: facebook/facebook-android-sdk

static void writeListTo(
    final Parcel out,
    int parcelFlags,
    final List<ShareMedia> media) {
  out.writeParcelableArray((ShareMedia[]) media.toArray(), parcelFlags);
}

代码示例来源:origin: facebook/facebook-android-sdk

static void writePhotoListTo(
    final Parcel out,
    int parcelFlags,
    final List<SharePhoto> photos) {
  ShareMedia[] array = new ShareMedia[photos.size()];
  for (int i = 0; i < photos.size(); ++i) {
    array[i] = photos.get(i);
  }
  out.writeParcelableArray(array, parcelFlags);
}

代码示例来源:origin: rockerhieu/emojicon

@Override
public void writeToParcel(Parcel out, int flags) {
  super.writeToParcel(out, flags);
  out.writeInt(this.type);
  out.writeParcelableArray(data, flags);
  out.writeInt(this.useSystemDefaults ? 1 : 0);
  out.writeInt(this.scrollX);
  out.writeInt(this.scrollY);
}

代码示例来源:origin: facebook/facebook-android-sdk

public void writeToParcel(final Parcel out, final int flags) {
  super.writeToParcel(out, flags);
  out.writeParcelableArray((ShareMedia[])this.media.toArray(), flags);
}

代码示例来源:origin: facebook/facebook-android-sdk

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeParcelableArray(handlersToTry, flags);
  dest.writeInt(currentHandler);
  dest.writeParcelable(pendingRequest, flags);
  Utility.writeStringMapToParcel(dest, loggingExtras);
  Utility.writeStringMapToParcel(dest, extraData);
}

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

@Override
public void writeToParcel(Parcel dest, int flags) {
  super.writeToParcel(dest, flags);
  dest.writeInt(this.torrentCount);
  dest.writeString(this.torrentUrl);
  dest.writeString(this.archiveUrl);
  dest.writeString(this.parent);
  dest.writeString(this.visible);
  dest.writeString(this.language);
  dest.writeString(this.size);
  dest.writeInt(this.pages);
  dest.writeInt(this.favoriteCount);
  dest.writeByte(isFavorited ? (byte) 1 : (byte) 0);
  dest.writeInt(this.ratingCount);
  dest.writeParcelableArray(this.tags, 0);
  dest.writeParcelableArray(this.comments, 0);
  dest.writeInt(this.previewPages);
  dest.writeParcelable(previewSet, flags);
  dest.writeString(this.favoriteName);
}

代码示例来源:origin: airbnb/epoxy

@Override
public void writeToParcel(Parcel parcel, int flags) {
 int size = size();
 int[] keys = new int[size];
 Parcelable[] values = new Parcelable[size];
 for (int i = 0; i < size; ++i) {
  keys[i] = keyAt(i);
  values[i] = valueAt(i);
 }
 parcel.writeInt(size);
 parcel.writeIntArray(keys);
 parcel.writeParcelableArray(values, flags);
}

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

dest.writeDouble(price);
dest.writeString(public_url);
dest.writeParcelableArray((ImageGroup[])images.toArray(), flags);
dest.writeParcelableArray((ProductInfo[])related.toArray(), flags);
dest.writeDouble(saleprice);
dest.writeString(sizes);

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

@Override
public void writeToParcel(Parcel dest, int flags) {
  Parcelable[] a;
  /* 
    some stuff to populate "a" with Arrival 
    objects (which implements Parcelable) 
  */
  dest.writeParcelableArray(a, 0);
}

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

public void writeToParcel(Parcel dest, int flags) {
 dest.writeInt(mElements.length);
 for(ArrayList<MyObject> element : mElements) {
  dest.writeParcelableArray(element.toArray(new MyObject[0]), flags);
 }
}

代码示例来源:origin: jclehner/rxdroid

@Override
public void writeToParcel(Parcel parcel, int flags)
{
  parcel.writeInt(mArray.length);
  for(int i = 0; i != mArray.length; ++i)
    parcel.writeParcelableArray(mArray[i], flags);
}

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

void writeToParcel(Parcel dest, int flags) {
  int numOfArrays = mArray.length;
  dest.writeInt(numOfArrays); // save number of arrays
  for (int i = 0; i < numOfArrays; i++) {
   dest.writeParcelableArray(mArray[i], flags);
  }
}

代码示例来源:origin: cn.leancloud.android/avoscloud-statistics

@Override
public void writeToParcel(Parcel out, int i) {
 out.writeParcelableArray(activities.toArray(new AnalyticsActivity[] {}),
   PARCELABLE_WRITE_RETURN_VALUE);
 out.writeParcelableArray(events.toArray(new AnalyticsEvent[] {}), PARCELABLE_WRITE_RETURN_VALUE);
 out.writeParcelable(duration, PARCELABLE_WRITE_RETURN_VALUE);
 out.writeString(sessionId);
}

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

@Override
public void writeToParcel(Parcel dest, int flags, Parcelable[] val) {
  dest.writeString(val.getClass().getComponentType().getName());
  dest.writeParcelableArray(val, flags);
}

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

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeString(mTargetClass);
  dest.writeString(mMethodName);
  if (flags == PARCELABLE_WRITE_RETURN_VALUE) {
    writeParcelableArrayToParcel(dest, mArgsWrapper, flags);
  } else {
    dest.writeParcelableArray(mArgsWrapper, flags);
  }
}

代码示例来源:origin: com.workday/postman

@Override
public final void writeToParcel(Parcel dest, int flags) {
  dest.writeParcelableArray(ParcelableAdapters.toParcelableArray(value), flags);
}

代码示例来源:origin: Workday/postman

@Override
public final void writeToParcel(Parcel dest, int flags) {
  dest.writeParcelableArray(ParcelableAdapters.toParcelableArray(value), flags);
}

代码示例来源:origin: com.workday/postman

@Override
public final void writeToParcel(Parcel dest, int flags) {
  final Parcelable[] keys = new Parcelable[value.size()];
  final Parcelable[] values = new Parcelable[value.size()];
  int i = 0;
  @SuppressWarnings("unchecked")
  final Map<Object, Object> castedMap = value;
  for (Map.Entry entry : castedMap.entrySet()) {
    keys[i] = ParcelableAdapters.asParcelable(entry.getKey());
    values[i] = ParcelableAdapters.asParcelable(entry.getValue());
  }
  dest.writeParcelableArray(keys, flags);
  dest.writeParcelableArray(values, flags);
}

代码示例来源:origin: Workday/postman

@Override
public final void writeToParcel(Parcel dest, int flags) {
  final Parcelable[] keys = new Parcelable[value.size()];
  final Parcelable[] values = new Parcelable[value.size()];
  int i = 0;
  @SuppressWarnings("unchecked")
  final Map<Object, Object> castedMap = value;
  for (Map.Entry entry : castedMap.entrySet()) {
    keys[i] = ParcelableAdapters.asParcelable(entry.getKey());
    values[i] = ParcelableAdapters.asParcelable(entry.getValue());
  }
  dest.writeParcelableArray(keys, flags);
  dest.writeParcelableArray(values, flags);
}

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

public LogChartData(Parcel source) {
  Parcelable[] parcelables = source.readParcelableArray(Thread
      .currentThread().getContextClassLoader());

   for (Parcelable parcelable : parcelables) {
    logs.add((LogEntries) parcelable);
   }
  }

@Override
public void writeToParcel(Parcel dest, int flags) {

  LogEntries[] data = new LogEntries[getLogs().size()];
  for (int i = 0; i < data.length; i++) {
     data[i] = getLogs().get(i);
  }
  dest.writeParcelableArray(data, flags);
}

相关文章

Parcel类方法