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

Implement bulk limit finally.

One bug is remaining, the setting is not properly selected
This commit is contained in:
Loic Blot 2015-11-04 00:48:08 +01:00
parent 64b580bcd3
commit eed1c9ec45

View File

@ -23,7 +23,6 @@ import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.util.Log;
import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs; import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs;
@ -55,9 +54,6 @@ public class SmsDataProvider extends ContentProvider {
} }
public Cursor queryNonExistingMessages(String mailBox, String existingIds) { public Cursor queryNonExistingMessages(String mailBox, String existingIds) {
OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(_context);
Integer bulkLimit = prefs.getSyncBulkLimit();
Log.d(TAG, "Bulk limit is " + bulkLimit.toString());
if (!existingIds.isEmpty()) { if (!existingIds.isEmpty()) {
return query(mailBox, "_id NOT IN (" + existingIds + ")"); return query(mailBox, "_id NOT IN (" + existingIds + ")");
} }
@ -68,7 +64,11 @@ public class SmsDataProvider extends ContentProvider {
public Cursor queryMessagesSinceDate(String mailBox, Long sinceDate) { public Cursor queryMessagesSinceDate(String mailBox, Long sinceDate) {
OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(_context); OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(_context);
Integer bulkLimit = prefs.getSyncBulkLimit(); Integer bulkLimit = prefs.getSyncBulkLimit();
Log.d(TAG, "Bulk limit is " + bulkLimit.toString()); String bulkStr = "";
if (bulkLimit > 0) {
bulkStr = "LIMIT " + bulkLimit.toString();
}
return query(mailBox, "date > ?", new String[] { sinceDate.toString() }); return query(mailBox, "date > ?", new String[] { sinceDate.toString() });
} }
@ -82,6 +82,14 @@ public class SmsDataProvider extends ContentProvider {
@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);
Integer bulkLimit = prefs.getSyncBulkLimit();
if (bulkLimit > 0) {
if (sortOrder == null)
sortOrder = "_id ";
sortOrder += " LIMIT " + bulkLimit.toString();
}
if ((_context != null) && (_context.getContentResolver() != null)) { if ((_context != null) && (_context.getContentResolver() != null)) {
return _context.getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder); return _context.getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder);
} }