mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-10 17:36:16 +00:00
SmsFetcher: do the cursor checks directly in SmsDataProviderAPI
This commit is contained in:
parent
8212ef63aa
commit
8395ac5bb4
@ -63,16 +63,6 @@ public class SmsFetcher {
|
||||
return;
|
||||
}
|
||||
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!c.moveToFirst()) {
|
||||
c.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// Reading mailbox
|
||||
do {
|
||||
JSONObject entry = new JSONObject();
|
||||
@ -108,18 +98,6 @@ public class SmsFetcher {
|
||||
return null;
|
||||
}
|
||||
|
||||
// or for a reason count returns zero value
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
|
||||
// If no first message into cursor
|
||||
if (!c.moveToFirst()) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
|
||||
// We create a list of strings to store results
|
||||
JSONArray results = new JSONArray();
|
||||
JSONObject entry = new JSONObject();
|
||||
@ -169,20 +147,6 @@ public class SmsFetcher {
|
||||
Log.i(SmsFetcher.TAG, "Retrieved " + c.getCount() + " messages.");
|
||||
} else {
|
||||
Log.i(SmsFetcher.TAG, "No message retrieved.");
|
||||
}
|
||||
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// Reading mailbox
|
||||
if (!c.moveToFirst()) {
|
||||
c.close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,22 @@ public class SmsDataProvider extends ContentProvider {
|
||||
|
||||
Log.i(SmsDataProvider.TAG, "query: selection set to " + selection);
|
||||
|
||||
return _context.getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder);
|
||||
Cursor cursor = _context.getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder);
|
||||
if (cursor == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (cursor.getCount() == 0) {
|
||||
cursor.close();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!cursor.moveToFirst()) {
|
||||
cursor.close();
|
||||
return null;
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user