1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.database; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 /** 23 * Describes the properties of a {@link CursorToBulkCursorAdaptor} that are 24 * needed to initialize its {@link BulkCursorToCursorAdaptor} counterpart on the client's end. 25 * 26 * {@hide} 27 */ 28 public final class BulkCursorDescriptor implements Parcelable { 29 public static final @android.annotation.NonNull Parcelable.Creator<BulkCursorDescriptor> CREATOR = 30 new Parcelable.Creator<BulkCursorDescriptor>() { 31 @Override 32 public BulkCursorDescriptor createFromParcel(Parcel in) { 33 BulkCursorDescriptor d = new BulkCursorDescriptor(); 34 d.readFromParcel(in); 35 return d; 36 } 37 38 @Override 39 public BulkCursorDescriptor[] newArray(int size) { 40 return new BulkCursorDescriptor[size]; 41 } 42 }; 43 44 public IBulkCursor cursor; 45 public String[] columnNames; 46 public boolean wantsAllOnMoveCalls; 47 public int count; 48 public CursorWindow window; 49 50 @Override describeContents()51 public int describeContents() { 52 return 0; 53 } 54 55 @Override writeToParcel(Parcel out, int flags)56 public void writeToParcel(Parcel out, int flags) { 57 out.writeStrongBinder(cursor.asBinder()); 58 out.writeStringArray(columnNames); 59 out.writeInt(wantsAllOnMoveCalls ? 1 : 0); 60 out.writeInt(count); 61 if (window != null) { 62 out.writeInt(1); 63 window.writeToParcel(out, flags); 64 } else { 65 out.writeInt(0); 66 } 67 } 68 readFromParcel(Parcel in)69 public void readFromParcel(Parcel in) { 70 cursor = BulkCursorNative.asInterface(in.readStrongBinder()); 71 columnNames = in.readStringArray(); 72 wantsAllOnMoveCalls = in.readInt() != 0; 73 count = in.readInt(); 74 if (in.readInt() != 0) { 75 window = CursorWindow.CREATOR.createFromParcel(in); 76 } 77 } 78 } 79