diff --git a/android-sdk/build.gradle b/android-sdk/build.gradle index 5df0293f..3e13c443 100644 --- a/android-sdk/build.gradle +++ b/android-sdk/build.gradle @@ -16,7 +16,7 @@ ext { siteUrl = 'https://getblueshift.com/' gitUrl = 'https://github.com/blueshift-labs/Blueshift-Android-SDK.git' - libraryVersion = '0.6.1' + libraryVersion = '0.6.2' developerId = 'nipun' developerName = 'Nipun Bhatia' @@ -133,7 +133,7 @@ if (project.hasProperty("android")) { // Android libraries source = android.sourceSets.main.java.srcDirs classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) // todo: remove below line when fixes are applied for excluding external aars for javadoc. - failOnError = false; + // failOnError = false; } } else { // Java libraries task sourcesJar(type: Jar, dependsOn: classes) { diff --git a/android-sdk/src/main/java/com/blueshift/framework/BaseSqliteTable.java b/android-sdk/src/main/java/com/blueshift/framework/BaseSqliteTable.java index 74a8adbc..33b63457 100644 --- a/android-sdk/src/main/java/com/blueshift/framework/BaseSqliteTable.java +++ b/android-sdk/src/main/java/com/blueshift/framework/BaseSqliteTable.java @@ -193,12 +193,17 @@ public ArrayList findAll() { if (db != null) { Cursor cursor = db.query(getTableName(), null, null, null, null, null, null); if (cursor != null) { - cursor.moveToFirst(); - while (!cursor.isAfterLast()) { - result.add(loadObject(cursor)); - cursor.moveToNext(); + if (cursor.moveToFirst()) { + while (!cursor.isAfterLast()) { + result.add(loadObject(cursor)); + cursor.moveToNext(); + } } + + cursor.close(); } + + db.close(); } } @@ -213,11 +218,11 @@ public ArrayList findWithLimit(int limit) { if (db != null) { Cursor cursor = db.rawQuery("SELECT * FROM " + getTableName() + " LIMIT " + limit, null); if (cursor != null) { - cursor.moveToFirst(); - - while (!cursor.isAfterLast()) { - result.add(loadObject(cursor)); - cursor.moveToNext(); + if (cursor.moveToFirst()) { + while (!cursor.isAfterLast()) { + result.add(loadObject(cursor)); + cursor.moveToNext(); + } } cursor.close(); @@ -239,9 +244,13 @@ public T findByField(String fieldName, String value) { if (db != null) { Cursor cursor = db.query(getTableName(), null, fieldName + "='" + value + "'", null, null, null, null); if (cursor != null) { - cursor.moveToFirst(); - object = loadObject(cursor); + if (cursor.moveToFirst()) { + object = loadObject(cursor); + } + + cursor.close(); } + db.close(); } } @@ -258,9 +267,13 @@ public T findByField(String fieldName, long value) { if (db != null) { Cursor cursor = db.query(getTableName(), null, fieldName + "=" + value, null, null, null, null); if (cursor != null) { - cursor.moveToFirst(); - object = loadObject(cursor); + if (cursor.moveToFirst()) { + object = loadObject(cursor); + } + + cursor.close(); } + db.close(); } } @@ -277,9 +290,13 @@ public T findRandomByField(String fieldName, long value) { if (db != null) { Cursor cursor = db.query(getTableName(), null, fieldName + "=" + value, null, null, null, "RANDOM()"); if (cursor != null) { - cursor.moveToFirst(); - object = loadObject(cursor); + if (cursor.moveToFirst()) { + object = loadObject(cursor); + } + + cursor.close(); } + db.close(); } } @@ -295,12 +312,17 @@ public ArrayList findAllByField(String fieldName, String value) { if (db != null) { Cursor cursor = db.query(getTableName(), null, fieldName + "='" + value + "'", null, null, null, null); if (cursor != null) { - cursor.moveToFirst(); - while (!cursor.isAfterLast()) { - result.add(loadObject(cursor)); - cursor.moveToNext(); + if (cursor.moveToFirst()) { + while (!cursor.isAfterLast()) { + result.add(loadObject(cursor)); + cursor.moveToNext(); + } } + + cursor.close(); } + + db.close(); } } @@ -320,12 +342,17 @@ public ArrayList findAllByField(String[] fieldNames, String[] values) { Cursor cursor = db.query(getTableName(), null, selection, values, null, null, null); if (cursor != null) { - cursor.moveToFirst(); - while (!cursor.isAfterLast()) { - result.add(loadObject(cursor)); - cursor.moveToNext(); + if (cursor.moveToFirst()) { + while (!cursor.isAfterLast()) { + result.add(loadObject(cursor)); + cursor.moveToNext(); + } } + + cursor.close(); } + + db.close(); } } @@ -346,12 +373,17 @@ public ArrayList findAllByField(String[] fieldNames, String[] values, int pag Cursor cursor = db.query(getTableName(), null, selection, values, null, null, order, String.valueOf(100 * pageNo)); if (cursor != null) { - cursor.moveToPosition(100 * (pageNo - 1)); - while (!cursor.isAfterLast()) { - result.add(loadObject(cursor)); - cursor.moveToNext(); + if (cursor.moveToPosition(100 * (pageNo - 1))) { + while (!cursor.isAfterLast()) { + result.add(loadObject(cursor)); + cursor.moveToNext(); + } } + + cursor.close(); } + + db.close(); } } @@ -372,12 +404,17 @@ public ArrayList findAllByField(String[] fieldNames, String[] values, int pag Cursor cursor = db.query(getTableName(), null, selection, values, null, null, order, String.valueOf(100 * pageNo)); if (cursor != null) { - cursor.moveToPosition(100 * (pageNo - 1)); - while (!cursor.isAfterLast()) { - result.add(loadObject(cursor)); - cursor.moveToNext(); + if (cursor.moveToPosition(100 * (pageNo - 1))) { + while (!cursor.isAfterLast()) { + result.add(loadObject(cursor)); + cursor.moveToNext(); + } } + + cursor.close(); } + + db.close(); } } diff --git a/dist/blueshift-android-sdk-0.6.1.aar b/dist/blueshift-android-sdk-0.6.1.aar deleted file mode 100644 index 22d13cf7..00000000 Binary files a/dist/blueshift-android-sdk-0.6.1.aar and /dev/null differ diff --git a/dist/blueshift-android-sdk-0.6.2.aar b/dist/blueshift-android-sdk-0.6.2.aar new file mode 100644 index 00000000..72290775 Binary files /dev/null and b/dist/blueshift-android-sdk-0.6.2.aar differ