mirror of https://github.com/M66B/FairEmail.git
Close cursors
This commit is contained in:
parent
e8816e4be2
commit
ddbdfcd522
|
@ -1109,7 +1109,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
|
|
||||||
boolean contacts = Helper.hasPermission(getContext(), Manifest.permission.READ_CONTACTS);
|
boolean contacts = Helper.hasPermission(getContext(), Manifest.permission.READ_CONTACTS);
|
||||||
if (contacts) {
|
if (contacts) {
|
||||||
Cursor cursor = resolver.query(
|
try (Cursor cursor = resolver.query(
|
||||||
ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
||||||
new String[]{
|
new String[]{
|
||||||
ContactsContract.Contacts.DISPLAY_NAME,
|
ContactsContract.Contacts.DISPLAY_NAME,
|
||||||
|
@ -1122,7 +1122,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
" OR LOWER(" + ContactsContract.Contacts.DISPLAY_NAME + ") GLOB ?" +
|
" OR LOWER(" + ContactsContract.Contacts.DISPLAY_NAME + ") GLOB ?" +
|
||||||
" OR " + ContactsContract.CommonDataKinds.Email.DATA + " LIKE ?)",
|
" OR " + ContactsContract.CommonDataKinds.Email.DATA + " LIKE ?)",
|
||||||
new String[]{wildcard, glob, wildcard},
|
new String[]{wildcard, glob, wildcard},
|
||||||
null);
|
null)) {
|
||||||
|
|
||||||
while (cursor != null && cursor.moveToNext()) {
|
while (cursor != null && cursor.moveToNext()) {
|
||||||
EntityContact item = new EntityContact();
|
EntityContact item = new EntityContact();
|
||||||
|
@ -1138,6 +1138,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
map.put(item.email, item);
|
map.put(item.email, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<EntityContact> items = new ArrayList<>();
|
List<EntityContact> items = new ArrayList<>();
|
||||||
if (suggest_sent)
|
if (suggest_sent)
|
||||||
|
|
|
@ -124,14 +124,15 @@ public class FtsDbHelper extends SQLiteOpenHelper {
|
||||||
static List<String> getSuggestions(SQLiteDatabase db, String query, int max) {
|
static List<String> getSuggestions(SQLiteDatabase db, String query, int max) {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
|
|
||||||
Cursor cursor = db.query(
|
try (Cursor cursor = db.query(
|
||||||
"SELECT term FROM message_terms" +
|
"SELECT term FROM message_terms" +
|
||||||
" WHERE term LIKE ?" +
|
" WHERE term LIKE ?" +
|
||||||
" ORDER BY cnt" +
|
" ORDER BY cnt" +
|
||||||
" LIMIT " + max,
|
" LIMIT " + max,
|
||||||
new Object[]{query});
|
new Object[]{query})) {
|
||||||
while (cursor != null && cursor.moveToNext())
|
while (cursor != null && cursor.moveToNext())
|
||||||
result.add(cursor.getString(0));
|
result.add(cursor.getString(0));
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class WorkerFts extends Worker {
|
||||||
|
|
||||||
SQLiteDatabase sdb = FtsDbHelper.getInstance(context);
|
SQLiteDatabase sdb = FtsDbHelper.getInstance(context);
|
||||||
|
|
||||||
Cursor cursor = db.message().getMessageFts();
|
try (Cursor cursor = db.message().getMessageFts()) {
|
||||||
while (cursor != null && cursor.moveToNext())
|
while (cursor != null && cursor.moveToNext())
|
||||||
try {
|
try {
|
||||||
long id = cursor.getLong(0);
|
long id = cursor.getLong(0);
|
||||||
|
@ -105,6 +105,7 @@ public class WorkerFts extends Worker {
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.e(ex);
|
Log.e(ex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
markIndexed(db, ids);
|
markIndexed(db, ids);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue