Panagiotis Triantafyllou

fixes

......@@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.5.4m5'
PUBLISH_VERSION = '4.5.5.4m6'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -151,8 +151,8 @@ public enum Warply {
private static void initInternal(Context context, boolean isNew) {
if (context != null) {
INSTANCE.check(context);
if (INSTANCE.mRequestQueue == null)
INSTANCE.mRequestQueue = Volley.newRequestQueue(context);
// if (INSTANCE.mRequestQueue == null)
INSTANCE.mRequestQueue = Volley.newRequestQueue(context);
INSTANCE.mContext = context.getApplicationContext();
WarpConstants.DEBUG = WarplyProperty.isDebugMode(INSTANCE.mContext);
INSTANCE.isInitializedOrThrow();
......@@ -1031,6 +1031,9 @@ public enum Warply {
WarpUtils.log("**********************************************************");
WarplyJsonObjectRequest request = new WarplyJsonObjectRequest(method, url, data, vt, vt);
request.setTag(tag);
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(mContext);
}
mRequestQueue.add(request);
}
......
......@@ -212,6 +212,12 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
return mDb;
}
private SQLiteDatabase getReadableDbInner() {
if (mDb == null)
mDb = getReadableDatabase(KEY_CIPHER);
return mDb;
}
/**
* Close database connection - should only be called when app is being destroyed
* or when database won't be used for a long time
......@@ -439,6 +445,7 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
}
//------------------------------ Api requests -----------------------------//
/**
* Gets all requests from the database.
* NOTE: The caller is responsible for closing the returned Cursor when done with it.
......@@ -518,24 +525,86 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
}
public synchronized long getRequestsInQueueCount() {
SQLiteDatabase db = getReadableDb();
long count = DatabaseUtils.queryNumEntries(db, TABLE_REQUESTS);
// Don't close the database here to improve performance
return count;
SQLiteDatabase db = getReadableDbInner();
if (db == null) {
Log.e("WarplyDBHelper", "Database is null in getRequestsInQueueCount()");
return 0;
}
// long count = DatabaseUtils.queryNumEntries(db, TABLE_REQUESTS);
// // Don't close the database here to improve performance
// return count;
Cursor cursor = null;
try {
cursor = db.rawQuery("SELECT COUNT(*) FROM " + TABLE_REQUESTS, null);
if (cursor != null && cursor.moveToFirst()) {
return cursor.getLong(0);
}
return 0;
} catch (Exception e) {
Log.e("WarplyDBHelper", "Error counting getRequestsInQueueCount", e);
return 0;
} finally {
if (cursor != null) {
cursor.close();
}
}
}
public synchronized long getPushRequestsInQueueCount() {
SQLiteDatabase db = getReadableDb();
long count = DatabaseUtils.queryNumEntries(db, TABLE_PUSH_REQUESTS);
// Don't close the database here to improve performance
return count;
SQLiteDatabase db = getReadableDbInner();
if (db == null) {
Log.e("WarplyDBHelper", "Database is null in getPushRequestsInQueueCount()");
return 0;
}
// long count = DatabaseUtils.queryNumEntries(db, TABLE_PUSH_REQUESTS);
// // Don't close the database here to improve performance
// return count;
Cursor cursor = null;
try {
cursor = db.rawQuery("SELECT COUNT(*) FROM " + TABLE_PUSH_REQUESTS, null);
if (cursor != null && cursor.moveToFirst()) {
return cursor.getLong(0);
}
return 0;
} catch (Exception e) {
Log.e("WarplyDBHelper", "Error counting getPushRequestsInQueueCount", e);
return 0;
} finally {
if (cursor != null) {
cursor.close();
}
}
}
public synchronized long getPushAckRequestsInQueueCount() {
SQLiteDatabase db = getReadableDb();
long count = DatabaseUtils.queryNumEntries(db, TABLE_PUSH_ACK_REQUESTS);
// Don't close the database here to improve performance
return count;
SQLiteDatabase db = getReadableDbInner();
if (db == null) {
Log.e("WarplyDBHelper", "Database is null in getPushAckRequestsInQueueCount()");
return 0;
}
// long count = DatabaseUtils.queryNumEntries(db, TABLE_PUSH_ACK_REQUESTS);
// // Don't close the database here to improve performance
// return count;
Cursor cursor = null;
try {
cursor = db.rawQuery("SELECT COUNT(*) FROM " + TABLE_PUSH_ACK_REQUESTS, null);
if (cursor != null && cursor.moveToFirst()) {
return cursor.getLong(0);
}
return 0;
} catch (Exception e) {
Log.e("WarplyDBHelper", "Error counting getPushAckRequestsInQueueCount", e);
return 0;
} finally {
if (cursor != null) {
cursor.close();
}
}
}
public synchronized void deleteRequests(Long... ids) {
......