what-the-bank/sources/com/google/android/gms/common/data/DataBufferSafeParcelable.java

45 lines
1.7 KiB
Java

package com.google.android.gms.common.data;
import android.content.ContentValues;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.android.gms.common.data.DataHolder;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
/* loaded from: classes.dex */
public class DataBufferSafeParcelable<T extends SafeParcelable> extends AbstractDataBuffer<T> {
private static final String[] zaa = {"data"};
private final Parcelable.Creator<T> zab;
public DataBufferSafeParcelable(DataHolder dataHolder, Parcelable.Creator<T> creator) {
super(dataHolder);
this.zab = creator;
}
public static <T extends SafeParcelable> void addValue(DataHolder.Builder builder, T t) {
Parcel obtain = Parcel.obtain();
t.writeToParcel(obtain, 0);
ContentValues contentValues = new ContentValues();
contentValues.put("data", obtain.marshall());
builder.withRow(contentValues);
obtain.recycle();
}
public static DataHolder.Builder buildDataHolder() {
return DataHolder.builder(zaa);
}
@Override // com.google.android.gms.common.data.AbstractDataBuffer, com.google.android.gms.common.data.DataBuffer
public T get(int i) {
DataHolder dataHolder = (DataHolder) Preconditions.checkNotNull(this.mDataHolder);
byte[] byteArray = dataHolder.getByteArray("data", i, dataHolder.getWindowIndex(i));
Parcel obtain = Parcel.obtain();
obtain.unmarshall(byteArray, 0, byteArray.length);
obtain.setDataPosition(0);
T createFromParcel = this.zab.createFromParcel(obtain);
obtain.recycle();
return createFromParcel;
}
}