1
0
mirror of https://github.com/nerzhul/ownCloud-SMS-App.git synced 2025-07-23 09:55:56 +00:00

Fix null cursor on lastmessage and prevent a double cursor close in same func

This commit is contained in:
Loic Blot 2016-08-29 00:16:17 +02:00
parent 783ed1dc00
commit 08b54f8aa0

View File

@ -70,7 +70,7 @@ public class SmsFetcher {
try { try {
String colName; String colName;
for(int idx=0;idx<c.getColumnCount();idx++) { for(int idx = 0; idx < c.getColumnCount(); idx++) {
colName = c.getColumnName(idx); colName = c.getColumnName(idx);
// Id column is must be an integer // Id column is must be an integer
@ -126,12 +126,15 @@ public class SmsFetcher {
// Fetch Sent SMS Message from Built-in Content Provider // Fetch Sent SMS Message from Built-in Content Provider
Cursor c = (new SmsDataProvider(_context)).query(mbURI); Cursor c = (new SmsDataProvider(_context)).query(mbURI);
if (c == null) {
return null;
}
c.moveToNext(); c.moveToNext();
// We create a list of strings to store results // We create a list of strings to store results
JSONArray results = new JSONArray(); JSONArray results = new JSONArray();
JSONObject entry = new JSONObject(); JSONObject entry = new JSONObject();
try { try {
@ -139,7 +142,7 @@ public class SmsFetcher {
String colName; String colName;
for(int idx = 0;idx < c.getColumnCount(); idx++) { for(int idx = 0;idx < c.getColumnCount(); idx++) {
colName = c.getColumnName(idx); colName = c.getColumnName(idx);
// Id column is must be an integer // Id column is must be an integer
switch (colName) { switch (colName) {
case "_id": case "_id":
@ -159,18 +162,17 @@ public class SmsFetcher {
break; break;
} }
} }
/* /*
* Mailbox ID is required by server * Mailbox ID is required by server
* mboxId is greater than server mboxId by 1 because types * mboxId is greater than server mboxId by 1 because types
* aren't indexed in the same mean * aren't indexed in the same mean
*/ */
entry.put("mbox", (mboxId - 1)); entry.put("mbox", (mboxId - 1));
results.put(entry); results.put(entry);
} catch (JSONException e) { } catch (JSONException e) {
Log.e(SmsFetcher.TAG, "JSON Exception when reading SMS Mailbox", e); Log.e(SmsFetcher.TAG, "JSON Exception when reading SMS Mailbox", e);
c.close();
} }
c.close(); c.close();