下面列出了android.os.Parcel#readTypedArray ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private PackageInfoLite(Parcel source) {
packageName = source.readString();
splitNames = source.createStringArray();
versionCode = source.readInt();
versionCodeMajor = source.readInt();
baseRevisionCode = source.readInt();
splitRevisionCodes = source.createIntArray();
recommendedInstallLocation = source.readInt();
installLocation = source.readInt();
multiArch = (source.readInt() != 0);
final int verifiersLength = source.readInt();
if (verifiersLength == 0) {
verifiers = new VerifierInfo[0];
} else {
verifiers = new VerifierInfo[verifiersLength];
source.readTypedArray(verifiers, VerifierInfo.CREATOR);
}
}
public ZenModeConfig(Parcel source) {
allowCalls = source.readInt() == 1;
allowRepeatCallers = source.readInt() == 1;
allowMessages = source.readInt() == 1;
allowReminders = source.readInt() == 1;
allowEvents = source.readInt() == 1;
allowCallsFrom = source.readInt();
allowMessagesFrom = source.readInt();
user = source.readInt();
manualRule = source.readParcelable(null);
final int len = source.readInt();
if (len > 0) {
final String[] ids = new String[len];
final ZenRule[] rules = new ZenRule[len];
source.readStringArray(ids);
source.readTypedArray(rules, ZenRule.CREATOR);
for (int i = 0; i < len; i++) {
automaticRules.put(ids[i], rules[i]);
}
}
allowAlarms = source.readInt() == 1;
allowMedia = source.readInt() == 1;
allowSystem = source.readInt() == 1;
suppressedVisualEffects = source.readInt();
areChannelsBypassingDnd = source.readInt() == 1;
}
private ExtendableSavedState(@NonNull Parcel in, ClassLoader loader) {
super(in, loader);
int size = in.readInt();
String[] keys = new String[size];
in.readStringArray(keys);
Bundle[] states = new Bundle[size];
in.readTypedArray(states, Bundle.CREATOR);
extendableStates = new SimpleArrayMap<>(size);
for (int i = 0; i < size; i++) {
extendableStates.put(keys[i], states[i]);
}
}
public SentenceSuggestionsInfo(Parcel source) {
final int infoSize = source.readInt();
mSuggestionsInfos = new SuggestionsInfo[infoSize];
source.readTypedArray(mSuggestionsInfos, SuggestionsInfo.CREATOR);
mOffsets = new int[mSuggestionsInfos.length];
source.readIntArray(mOffsets);
mLengths = new int[mSuggestionsInfos.length];
source.readIntArray(mLengths);
}
@Override
public NdefMessage createFromParcel(Parcel in) {
int recordsLength = in.readInt();
NdefRecord[] records = new NdefRecord[recordsLength];
in.readTypedArray(records, NdefRecord.CREATOR);
return new NdefMessage(records);
}
@Override
public BeamShareData createFromParcel(Parcel source) {
Uri[] uris = null;
NdefMessage msg = source.readParcelable(NdefMessage.class.getClassLoader());
int numUris = source.readInt();
if (numUris > 0) {
uris = new Uri[numUris];
source.readTypedArray(uris, Uri.CREATOR);
}
UserHandle userHandle = source.readParcelable(UserHandle.class.getClassLoader());
int flags = source.readInt();
return new BeamShareData(msg, uris, userHandle, flags);
}
@Override
public ActivityChangedEvent createFromParcel(Parcel source) {
int activityRecognitionEventsLength = source.readInt();
ActivityRecognitionEvent[] activityRecognitionEvents =
new ActivityRecognitionEvent[activityRecognitionEventsLength];
source.readTypedArray(activityRecognitionEvents, ActivityRecognitionEvent.CREATOR);
return new ActivityChangedEvent(activityRecognitionEvents);
}
protected SlotsList(Parcel in) {
this.size = in.readInt();
if (size > 0) {
Slot[] slots = new Slot[this.size];
in.readTypedArray(slots, Slot.CREATOR);
linkSlots(slots, this);
}
}
/**
* Constructor called from {@link #CREATOR}
*/
private SavedState(Parcel in) {
super(in);
int length = in.readInt();
if(length > 0){
recipients = new Recipient[length];
in.readTypedArray(recipients, Recipient.CREATOR);
}
}
@Override
public BeamShareData createFromParcel(Parcel source) {
Uri[] uris = null;
NdefMessage msg = source.readParcelable(NdefMessage.class.getClassLoader());
int numUris = source.readInt();
if (numUris > 0) {
uris = new Uri[numUris];
source.readTypedArray(uris, Uri.CREATOR);
}
UserHandle userHandle = source.readParcelable(UserHandle.class.getClassLoader());
int flags = source.readInt();
return new BeamShareData(msg, uris, userHandle, flags);
}
public DesfireApplication createFromParcel(Parcel source) {
int id = source.readInt();
DesfireFile[] files = new DesfireFile[source.readInt()];
source.readTypedArray(files, DesfireFile.CREATOR);
return new DesfireApplication(id, files);
}
public T readFromParcel(Parcel in) {
T entity = type.getFactory().get();
EntityProxy<T> proxy = type.getProxyProvider().apply(entity);
for (Attribute<T, ?> attribute : type.getAttributes()) {
if (attribute.isAssociation()) {
continue;
}
Class<?> typeClass = attribute.getClassType();
Object value = null;
if (typeClass.isEnum()) {
String name = (String) in.readValue(getClass().getClassLoader());
if (name == null) {
value = null;
} else {
@SuppressWarnings("unchecked")
Class<? extends Enum> enumClass = (Class<? extends Enum>) typeClass;
value = Enum.valueOf(enumClass, name);
}
} else if (typeClass.isArray()) {
int length = in.readInt();
if (length >= 0) {
try {
Parcelable.Creator creator = (Parcelable.Creator<?>)
typeClass.getField("CREATOR").get(null);
Object[] array = creator.newArray(length);
in.readTypedArray(array, creator);
value = array;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
} else {
value = in.readValue(getClass().getClassLoader());
}
PropertyState state = PropertyState.LOADED;
if (!type.isStateless()) {
state = PropertyState.valueOf(in.readString());
}
proxy.setObject(attribute, value, state);
}
return entity;
}