mirror of
https://github.com/moparisthebest/android_external_GmsApi
synced 2024-11-27 11:02:18 -05:00
Add DataHolder and SignInButtonCreator
This commit is contained in:
parent
adb160c25b
commit
4b5be5f4bb
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.microg.gms.api">
|
package="org.microg.gms.api">
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="9"/>
|
<uses-sdk android:minSdkVersion="9" />
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit a650ca5beac2a374460d820935b40f9539e692db
|
Subproject commit 462316b18e2620bd5c0cb843abd67671d941300d
|
@ -1,11 +1,91 @@
|
|||||||
package com.google.android.gms.common.data;
|
package com.google.android.gms.common.data;
|
||||||
|
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.CursorWindow;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
import org.microg.safeparcel.AutoSafeParcelable;
|
import org.microg.safeparcel.AutoSafeParcelable;
|
||||||
import org.microg.safeparcel.SafeParceled;
|
import org.microg.safeparcel.SafeParceled;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for accessing collections of data, organized into columns. This provides the backing
|
||||||
|
* support for DataBuffer. Much like a cursor, the holder supports the notion of a current
|
||||||
|
* position, and has methods for extracting various types of data from named columns.
|
||||||
|
*/
|
||||||
public class DataHolder extends AutoSafeParcelable {
|
public class DataHolder extends AutoSafeParcelable {
|
||||||
@SafeParceled(1000)
|
@SafeParceled(1000)
|
||||||
private int versionCode = 1;
|
private int versionCode = 1;
|
||||||
|
|
||||||
|
@SafeParceled(1)
|
||||||
|
private String[] columns;
|
||||||
|
|
||||||
|
@SafeParceled(2)
|
||||||
|
private CursorWindow[] windows;
|
||||||
|
|
||||||
|
@SafeParceled(3)
|
||||||
|
private int statusCode;
|
||||||
|
|
||||||
|
@SafeParceled(4)
|
||||||
|
private Bundle metadata;
|
||||||
|
|
||||||
|
public DataHolder(String[] columns, CursorWindow[] windows, int statusCode, Bundle metadata) {
|
||||||
|
this.columns = columns;
|
||||||
|
this.windows = windows;
|
||||||
|
this.statusCode = statusCode;
|
||||||
|
this.metadata = metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static DataHolder fromCursor(Cursor cursor, int statusCode, Bundle metadata) {
|
||||||
|
List<CursorWindow> windows = new ArrayList<>();
|
||||||
|
CursorWindow cursorWindow = null;
|
||||||
|
int row = 0;
|
||||||
|
while (cursor.moveToNext()) {
|
||||||
|
if (cursorWindow == null || !cursorWindow.allocRow()) {
|
||||||
|
cursorWindow = new CursorWindow(false);
|
||||||
|
cursorWindow.setNumColumns(cursor.getColumnCount());
|
||||||
|
windows.add(cursorWindow);
|
||||||
|
row = 0;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < cursor.getColumnCount(); i++) {
|
||||||
|
switch (cursor.getType(i)) {
|
||||||
|
case Cursor.FIELD_TYPE_NULL:
|
||||||
|
cursorWindow.putNull(row, i);
|
||||||
|
break;
|
||||||
|
case Cursor.FIELD_TYPE_BLOB:
|
||||||
|
cursorWindow.putBlob(cursor.getBlob(i), row, i);
|
||||||
|
break;
|
||||||
|
case Cursor.FIELD_TYPE_FLOAT:
|
||||||
|
cursorWindow.putDouble(cursor.getDouble(i), row, i);
|
||||||
|
break;
|
||||||
|
case Cursor.FIELD_TYPE_INTEGER:
|
||||||
|
cursorWindow.putLong(cursor.getLong(i), row, i);
|
||||||
|
break;
|
||||||
|
case Cursor.FIELD_TYPE_STRING:
|
||||||
|
cursorWindow.putString(cursor.getString(i), row, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
DataHolder dataHolder = new DataHolder(cursor.getColumnNames(), windows.toArray(new CursorWindow[windows.size()]), statusCode, metadata);
|
||||||
|
cursor.close();
|
||||||
|
return dataHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DataHolder{" +
|
||||||
|
"columns=" + Arrays.toString(columns) +
|
||||||
|
", windows=" + Arrays.toString(windows) +
|
||||||
|
", statusCode=" + statusCode +
|
||||||
|
", metadata=" + metadata +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
public static final Creator<DataHolder> CREATOR = new AutoCreator<>(DataHolder.class);
|
public static final Creator<DataHolder> CREATOR = new AutoCreator<>(DataHolder.class);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.google.android.gms.common.internal;
|
||||||
|
|
||||||
|
import com.google.android.gms.dynamic.IObjectWrapper;
|
||||||
|
|
||||||
|
interface ISignInButtonCreator {
|
||||||
|
IObjectWrapper createSignInButton(IObjectWrapper context, int size, int color); // returns View
|
||||||
|
}
|
@ -3,5 +3,6 @@ package com.google.android.gms.people.internal;
|
|||||||
import com.google.android.gms.common.data.DataHolder;
|
import com.google.android.gms.common.data.DataHolder;
|
||||||
|
|
||||||
interface IPeopleCallbacks {
|
interface IPeopleCallbacks {
|
||||||
void onDataHolders(int code, in Bundle meta, in DataHolder[] data) = 3;
|
void onDataHolder(int code, in Bundle resolution, in DataHolder holder) = 1;
|
||||||
|
void onDataHolders(int code, in Bundle resolution, in DataHolder[] holders) = 3;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user