Switch to gradle/maven project structure

This commit is contained in:
mar-v-in 2015-03-13 00:13:22 +01:00
parent 1510aa1b0a
commit 32663c095b
160 changed files with 41 additions and 16 deletions

View File

@ -10,19 +10,10 @@ buildscript {
apply plugin: 'com.android.library'
dependencies {
compile project(':SafeParcel')
compile project('SafeParcel')
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
lintOptions.abortOnError false
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
}
}
}

View File

@ -1,7 +1,10 @@
package com.google.android.gms.common.data;
import android.annotation.SuppressLint;
import android.database.AbstractWindowedCursor;
import android.database.Cursor;
import android.database.CursorWindow;
import android.os.Build;
import android.os.Bundle;
import org.microg.safeparcel.AutoSafeParcelable;
@ -39,6 +42,37 @@ public class DataHolder extends AutoSafeParcelable {
this.metadata = metadata;
}
protected static final int FIELD_TYPE_BLOB = 4;
protected static final int FIELD_TYPE_FLOAT = 2;
protected static final int FIELD_TYPE_INTEGER = 1;
protected static final int FIELD_TYPE_NULL = 0;
protected static final int FIELD_TYPE_STRING = 3;
@SuppressLint("NewApi")
static int getCursorType(Cursor cursor, int i) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
return cursor.getType(i);
}
if (cursor instanceof AbstractWindowedCursor) {
CursorWindow cursorWindow = ((AbstractWindowedCursor)cursor).getWindow();
int pos = cursor.getPosition();
int type = -1;
if (cursorWindow.isNull(pos, i)) {
type = FIELD_TYPE_NULL;
} else if (cursorWindow.isLong(pos, i)) {
type = FIELD_TYPE_INTEGER;
} else if (cursorWindow.isFloat(pos, i)) {
type = FIELD_TYPE_FLOAT;
} else if (cursorWindow.isString(pos, i)) {
type = FIELD_TYPE_STRING;
} else if (cursorWindow.isBlob(pos, i)) {
type = FIELD_TYPE_BLOB;
}
return type;
}
throw new RuntimeException("Unsupported cursor on this platform!");
}
public static DataHolder fromCursor(Cursor cursor, int statusCode, Bundle metadata) {
List<CursorWindow> windows = new ArrayList<>();
@ -54,20 +88,20 @@ public class DataHolder extends AutoSafeParcelable {
row = 0;
}
for (int i = 0; i < cursor.getColumnCount(); i++) {
switch (cursor.getType(i)) {
case Cursor.FIELD_TYPE_NULL:
switch (getCursorType(cursor, i)) {
case FIELD_TYPE_NULL:
cursorWindow.putNull(row, i);
break;
case Cursor.FIELD_TYPE_BLOB:
case FIELD_TYPE_BLOB:
cursorWindow.putBlob(cursor.getBlob(i), row, i);
break;
case Cursor.FIELD_TYPE_FLOAT:
case FIELD_TYPE_FLOAT:
cursorWindow.putDouble(cursor.getDouble(i), row, i);
break;
case Cursor.FIELD_TYPE_INTEGER:
case FIELD_TYPE_INTEGER:
cursorWindow.putLong(cursor.getLong(i), row, i);
break;
case Cursor.FIELD_TYPE_STRING:
case FIELD_TYPE_STRING:
cursorWindow.putString(cursor.getString(i), row, i);
break;
}

Some files were not shown because too many files have changed in this diff Show More