1
0
mirror of https://github.com/nerzhul/ownCloud-SMS-App.git synced 2025-06-08 08:26:09 +00:00

Cleanup a little bit SmsDataProvider

This commit is contained in:
Loic Blot 2016-08-28 22:31:03 +02:00
parent 58ef25883c
commit 0e71ca5fa1
2 changed files with 10 additions and 25 deletions

View File

@ -204,9 +204,8 @@ 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
switch (colName) { switch (colName) {
// Id column is must be an integer
case "_id": case "_id":
case "type": case "type":
entry.put(colName, c.getInt(idx)); entry.put(colName, c.getInt(idx));

View File

@ -46,44 +46,30 @@ public class SmsDataProvider extends ContentProvider {
); );
} }
public Cursor query(String mailBox, String selection) {
return query(Uri.parse(mailBox),
new String[] { "read", "date", "address", "seen", "body", "_id", "type", },
selection, null, null
);
}
public Cursor queryNonExistingMessages(String mailBox, String existingIds) { public Cursor queryNonExistingMessages(String mailBox, String existingIds) {
if (!existingIds.isEmpty()) { if (!existingIds.isEmpty()) {
return query(mailBox, "_id NOT IN (" + existingIds + ")"); return query(Uri.parse(mailBox),
new String[] { "read", "date", "address", "seen", "body", "_id", "type", },
"_id NOT IN (" + existingIds + ")", null, null
);
} }
return query(mailBox); return query(mailBox);
} }
public Cursor queryMessagesSinceDate(String mailBox, Long sinceDate) { public Cursor queryMessagesSinceDate(String mailBox, Long sinceDate) {
OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(_context); return query(Uri.parse(mailBox),
Integer bulkLimit = prefs.getSyncBulkLimit(); new String[] { "read", "date", "address", "seen", "body", "_id", "type", },
String bulkStr = ""; "date > ?", new String[] { sinceDate.toString() }, null
if (bulkLimit > 0) { );
bulkStr = "LIMIT " + bulkLimit.toString();
}
return query(mailBox, "date > ?", new String[] { sinceDate.toString() });
} }
public Cursor query(String mailBox, String selection, String[] selectionArgs) {
return query(Uri.parse(mailBox),
new String[] { "read", "date", "address", "seen", "body", "_id", "type", },
selection, selectionArgs, null
);
}
@Override @Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection, public Cursor query(@NonNull Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) { String[] selectionArgs, String sortOrder) {
OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(_context); OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(_context);
Integer bulkLimit = prefs.getSyncBulkLimit(); Integer bulkLimit = prefs.getSyncBulkLimit();
//Integer senderMinSize = prefs.getMinPhoneNumberCharsToSync();
if (bulkLimit > 0) { if (bulkLimit > 0) {
if (sortOrder == null) if (sortOrder == null)
sortOrder = "_id "; sortOrder = "_id ";