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

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

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

Parcel.readParcelableArray介绍

[英]Read and return a new Parcelable array from the parcel. The given class loader will be used to load any enclosed Parcelables.
[中]从包裹中读取并返回新的包裹数组。给定的类装入器将用于装入任何封闭的包裹。

代码示例

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

ShareMediaContent(final Parcel in) {
  super(in);
  ShareMedia[] shareMedia = (ShareMedia[])in.readParcelableArray(
      ShareMedia.class.getClassLoader());
  this.media = Arrays.asList(shareMedia);
}

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

static List<ShareMedia> readListFrom(final Parcel in) {
    Parcelable[] parcelables = in.readParcelableArray(
        ShareMedia.class.getClassLoader());
    List<ShareMedia> shareMedia = new ArrayList<>(parcelables.length);
    for (Parcelable parcelable : parcelables) {
      shareMedia.add((ShareMedia) parcelable);
    }
    return shareMedia;
  }
}

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

private SavedState(Parcel in) {
  super(in);
  //noinspection WrongConstant
  this.type = in.readInt();
  this.data = (Emojicon[]) in.readParcelableArray(Emojicon.class.getClassLoader());
  this.useSystemDefaults = in.readInt() != 0;
  this.scrollX = in.readInt();
  this.scrollY = in.readInt();
}

代码示例来源:origin: rey5137/material

break;
case MODE_ITEMS: {
  Parcelable[] values = in.readParcelableArray(null);
  if (values != null && values.length > 0) {
    mItems = new CharSequence[values.length];
  Parcelable[] values = in.readParcelableArray(null);
  if (values != null && values.length > 0) {
    mItems = new CharSequence[values.length];

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

public LoginClient(Parcel source) {
  Object [] o = source.readParcelableArray(LoginMethodHandler.class.getClassLoader());
  handlersToTry = new LoginMethodHandler[o.length];
  for (int i = 0; i < o.length; ++i) {
    handlersToTry[i] = (LoginMethodHandler) o[i];
    handlersToTry[i].setLoginClient(this);
  }
  currentHandler = source.readInt();
  pendingRequest = source.readParcelable(Request.class.getClassLoader());
  loggingExtras = Utility.readStringMapFromParcel(source);
  extraData = Utility.readStringMapFromParcel(source);
}

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

protected GalleryDetail(Parcel in) {
  super(in);
  this.torrentCount = in.readInt();
  this.torrentUrl = in.readString();
  this.archiveUrl = in.readString();
  this.parent = in.readString();
  this.visible = in.readString();
  this.language = in.readString();
  this.size = in.readString();
  this.pages = in.readInt();
  this.favoriteCount = in.readInt();
  this.isFavorited = in.readByte() != 0;
  this.ratingCount = in.readInt();
  Parcelable[] array = in.readParcelableArray(GalleryTagGroup.class.getClassLoader());
  if (array != null) {
    this.tags = Arrays.copyOf(array, array.length, GalleryTagGroup[].class);
  } else {
    this.tags = null;
  }
  array = in.readParcelableArray(GalleryComment.class.getClassLoader());
  if (array != null) {
    this.comments = Arrays.copyOf(array, array.length, GalleryComment[].class);
  } else {
    this.comments = null;
  }
  this.previewPages = in.readInt();
  this.previewSet = in.readParcelable(PreviewSet.class.getClassLoader());
  this.favoriteName = in.readString();
}

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

private Wrapper(Parcel in) {
 int length = in.readInt();
 //Declare list
 for (int i = 0; i < length; i++) {
  MyObject[] read = in.readParcelableArray(Wrapper.class.getClassLoader());
  //add to list
 }
}

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

public Book(Parcel in) {
  id  = in.readInt();
  this.title = in.readString();
  this.price = in.readString();
  this.isbn = in.readString();
  this.authors = in.readParcelableArray(Author.class.getClassLoader());
}

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

AnalyticsSession(Parcel in) {
 this();
 Parcelable[] parcelActivities =
   in.readParcelableArray(AnalyticsActivity.class.getClassLoader());
 Parcelable[] parcelEvents = in.readParcelableArray(AnalyticsEvent.class.getClassLoader());
 for (Parcelable activity : parcelActivities) {
  activities.add((AnalyticsActivity) activity);
 }
 for (Parcelable event : parcelEvents) {
  events.add((AnalyticsEvent) event);
 }
 this.duration = in.readParcelable(AVDuration.class.getClassLoader());
 this.sessionId = in.readString();
}

代码示例来源: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);
}

代码示例来源:origin: TrustWallet/trust-wallet-android-source

protected Transaction(Parcel in) {
  hash = in.readString();
  error = in.readString();
  blockNumber = in.readString();
  timeStamp = in.readLong();
  nonce = in.readInt();
  from = in.readString();
  to = in.readString();
  value = in.readString();
  gas = in.readString();
  gasPrice = in.readString();
  input = in.readString();
  gasUsed = in.readString();
  Parcelable[] parcelableArray = in.readParcelableArray(TransactionOperation.class.getClassLoader());
  TransactionOperation[] operations = null;
  if (parcelableArray != null) {
    operations = Arrays.copyOf(parcelableArray, parcelableArray.length, TransactionOperation[].class);
  }
  this.operations = operations;
}

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

@Override
public final C createFromParcel(Parcel source) {
  final Parcelable[] wrapped =
      source.readParcelableArray(ParcelableAdapter.class.getClassLoader());
  final List<Object> unwrapped =
      Arrays.asList(ParcelableAdapters.unwrapParcelableArray(wrapped));
  return newParcelableAdapterInstance(unwrapped);
}

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

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

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

}

public A(Parcel in) {
  Parcelable[] parcelables = in.readParcelableArray(Thread
      .currentThread().getContextClassLoader());
  ArrayList<B> list = new ArrayList<B>();
  for (Parcelable parcelable : parcelables) {
    list.add((B) parcelable);
  }
  var = list;
}

代码示例来源:origin: JessYanCoding/MVPArt

private void readFromParcel(Parcel source) {
    what = source.readInt();
    arg1 = source.readInt();
    arg2 = source.readInt();
    str = source.readString();
    presenter = source.readString();
    if (source.readInt() != 0) {
      obj = source.readParcelable(getClass().getClassLoader());
    }
    if (source.readInt() != 0) {
      objs = source.readParcelableArray(getClass().getClassLoader());
    }
    data = source.readBundle();
    replyTo = Messenger.readMessengerOrNullFromParcel(source);
    sendingUid = source.readInt();
  }
}

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

@Override
public final C createFromParcel(Parcel source) {
  final Parcelable[] wrapped =
      source.readParcelableArray(ParcelableAdapter.class.getClassLoader());
  final List<Object> unwrapped =
      Arrays.asList(ParcelableAdapters.unwrapParcelableArray(wrapped));
  return newParcelableAdapterInstance(unwrapped);
}

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

for (Parcelable p : source.readParcelableArray(MyParcelable.class.getClassLoader()))
  add((MyParcelable) p);

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

public List<Edge> adjacencies = new ArrayList<Edge>();

public Edge(Parcel in) {
  name = in.getString();
  minDistance = in.getDouble();
  adjancencies = in.readParcelableArray(Edge.getClass().getClassLoader()); 
}

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeString(name);
  dest.writeDouble(minDistance);
  pc.writeParcelableArray((ArrayList<? extends Parcelable>) adjacencies, flags);

}

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

@Override
public final A createFromParcel(Parcel source) {
  final Parcelable[] keys =
      source.readParcelableArray(ParcelableAdapter.class.getClassLoader());
  final Parcelable[] values =
      source.readParcelableArray(ParcelableAdapter.class.getClassLoader());
  if (keys.length != values.length) {
    final String message = String.format(Locale.US,
                       "Length of keys array (%d) does not match "
                           + "length of values array (%d)",
                       keys.length,
                       values.length);
    throw new IllegalStateException(message);
  }
  final M map = newMapInstance();
  @SuppressWarnings("unchecked")
  final Map<Object, Object> castedMap = (Map<Object, Object>) map;
  for (int i = 0; i < keys.length; i++) {
    final Object key = ParcelableAdapters.unwrapParcelable(keys[i]);
    final Object value = ParcelableAdapters.unwrapParcelable(values[i]);
    castedMap.put(key, value);
  }
  return newParcelableAdapterInstance(map);
}

代码示例来源:origin: MFlisar/GDPRDialog

public GDPRSetup(Parcel in) {
  mPolicyLink = in.readString();
  mHasPaidVersion = in.readByte() == 1;
  mAllowNonPersonalisedForPaidVersion = in.readByte() == 1;
  mAllowNoConsent = in.readByte() == 1;
  Parcelable[] adNetworks = in.readParcelableArray(GDPRNetwork.class.getClassLoader());
  mNetworks = new GDPRNetwork[adNetworks.length];
  for (int i = 0; i < adNetworks.length; i++) {
    mNetworks[i] = (GDPRNetwork) adNetworks[i];
  }
  mExplicitAgeConfirmation = in.readByte() == 1;
  mExplicitNonPersonalisedConfirmation = in.readByte() == 1;
  mNoToolbarTheme = in.readByte() == 1;
  int requestLocationsCount = in.readInt();
  mRequestLocationChecks = new GDPRLocationCheck[requestLocationsCount];
  int[] requestLocations = new int[requestLocationsCount];
  if (requestLocationsCount > 0)
    in.readIntArray(requestLocations);
  for (int i = 0; i < requestLocationsCount; i++) {
    mRequestLocationChecks[i] = GDPRLocationCheck.values()[requestLocations[i]];
  }
  mUseBottomSheet = in.readByte() == 1;
  mForceSelection = in.readByte() == 1;
  mCustomDialogTheme = in.readInt();
  mShortQuestion = in.readByte() == 1;
  in.readStringList(mPublisherIds);
  mConnectionReadTimeout = in.readInt();
  mConnectionConnectTimeout = in.readInt();
  mShowPaidOrFreeInfoText = in.readByte() == 1;
}

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

@Override
public final A createFromParcel(Parcel source) {
  final Parcelable[] keys =
      source.readParcelableArray(ParcelableAdapter.class.getClassLoader());
  final Parcelable[] values =
      source.readParcelableArray(ParcelableAdapter.class.getClassLoader());
  if (keys.length != values.length) {
    final String message = String.format(Locale.US,
                       "Length of keys array (%d) does not match "
                           + "length of values array (%d)",
                       keys.length,
                       values.length);
    throw new IllegalStateException(message);
  }
  final M map = newMapInstance();
  @SuppressWarnings("unchecked")
  final Map<Object, Object> castedMap = (Map<Object, Object>) map;
  for (int i = 0; i < keys.length; i++) {
    final Object key = ParcelableAdapters.unwrapParcelable(keys[i]);
    final Object val = ParcelableAdapters.unwrapParcelable(values[i]);
    castedMap.put(key, val);
  }
  return newParcelableAdapterInstance(map);
}

相关文章

Parcel类方法