Fix unclosed cursors
This commit is contained in:
parent
b3262c905a
commit
072e95280d
|
@ -222,8 +222,10 @@ public class BoostScheduleDAO {
|
|||
*/
|
||||
private StoredStatus cursorToStoredStatus(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
//Take the first element
|
||||
c.moveToFirst();
|
||||
//New user
|
||||
|
@ -255,8 +257,10 @@ public class BoostScheduleDAO {
|
|||
*/
|
||||
private List<StoredStatus> cursorToListStatuses(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
List<StoredStatus> storedStatuses = new ArrayList<>();
|
||||
while (c.moveToNext() ) {
|
||||
//Restore the status
|
||||
|
|
|
@ -166,8 +166,10 @@ public class CustomEmojiDAO {
|
|||
*/
|
||||
private Emojis cursorToEmoji(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
//Take the first element
|
||||
c.moveToFirst();
|
||||
//New user
|
||||
|
@ -188,8 +190,10 @@ public class CustomEmojiDAO {
|
|||
*/
|
||||
private List<Emojis> cursorToListEmojis(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
List<Emojis> emojis = new ArrayList<>();
|
||||
while (c.moveToNext() ) {
|
||||
//Restore the emojis
|
||||
|
|
|
@ -100,8 +100,10 @@ public class DomainBlockDAO {
|
|||
*/
|
||||
private List<String> cursorToDomain(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
List<String> domains = new ArrayList<>();
|
||||
while (c.moveToNext() ) {
|
||||
domains.add(c.getString(c.getColumnIndex(Sqlite.COL_DOMAIN)));
|
||||
|
|
|
@ -126,8 +126,10 @@ public class PeertubeFavoritesDAO {
|
|||
*/
|
||||
private List<Peertube> cursorToListPeertube(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
List<Peertube> peertubes = new ArrayList<>();
|
||||
while (c.moveToNext() ) {
|
||||
//Restore cached status
|
||||
|
|
|
@ -339,8 +339,10 @@ public class StatusCacheDAO {
|
|||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_STATUSES_CACHE, null, Sqlite.COL_CACHED_ACTION + " = '" + cacheType+ "' AND " + Sqlite.COL_INSTANCE + " = '" + instance+ "' AND " + Sqlite.COL_USER_ID + " = '" + userId+ "'", null, null, null, Sqlite.COL_DATE_BACKUP + " DESC", "1");
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
//Take the first element
|
||||
c.moveToFirst();
|
||||
String date = c.getString(c.getColumnIndex(Sqlite.COL_DATE_BACKUP));
|
||||
|
@ -362,8 +364,10 @@ public class StatusCacheDAO {
|
|||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_STATUSES_CACHE, null, Sqlite.COL_CACHED_ACTION + " = '" + cacheType+ "' AND " + Sqlite.COL_INSTANCE + " = '" + instance+ "' AND " + Sqlite.COL_USER_ID + " = '" + userId+ "'", null, null, null, Sqlite.COL_CREATED_AT + " ASC", "1");
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
//Take the first element
|
||||
c.moveToFirst();
|
||||
String date = c.getString(c.getColumnIndex(Sqlite.COL_CREATED_AT));
|
||||
|
@ -385,8 +389,10 @@ public class StatusCacheDAO {
|
|||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_STATUSES_CACHE, null, Sqlite.COL_CACHED_ACTION + " = '" + cacheType+ "' AND " + Sqlite.COL_INSTANCE + " = '" + instance+ "' AND " + Sqlite.COL_USER_ID + " = '" + userId+ "'", null, null, null, Sqlite.COL_CREATED_AT + " DESC", "1");
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
//Take the first element
|
||||
c.moveToFirst();
|
||||
String date = c.getString(c.getColumnIndex(Sqlite.COL_CREATED_AT));
|
||||
|
@ -408,8 +414,10 @@ public class StatusCacheDAO {
|
|||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_STATUSES_CACHE, null, Sqlite.COL_CACHED_ACTION + " = '" + cacheType+ "' AND " + Sqlite.COL_INSTANCE + " = '" + instance+ "' AND " + Sqlite.COL_USER_ID + " = '" + userId+ "'", null, null, null, Sqlite.COL_STATUS_ID + " DESC", "1");
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
//Take the first element
|
||||
c.moveToFirst();
|
||||
String last_id = c.getString(c.getColumnIndex(Sqlite.COL_STATUS_ID));
|
||||
|
@ -433,8 +441,10 @@ public class StatusCacheDAO {
|
|||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_STATUSES_CACHE, null, Sqlite.COL_CACHED_ACTION + " = '" + cacheType+ "' AND " + Sqlite.COL_INSTANCE + " = '" + instance+ "' AND " + Sqlite.COL_USER_ID + " = '" + userId+ "'", null, null, null, Sqlite.COL_CREATED_AT + " DESC", "1");
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
//Take the first element
|
||||
c.moveToFirst();
|
||||
Date last_id = Helper.stringToDate(context, c.getString(c.getColumnIndex(Sqlite.COL_CREATED_AT)));
|
||||
|
@ -696,8 +706,10 @@ public class StatusCacheDAO {
|
|||
*/
|
||||
private Status cursorToStoredStatus(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
//Take the first element
|
||||
c.moveToFirst();
|
||||
//New status
|
||||
|
@ -740,8 +752,10 @@ public class StatusCacheDAO {
|
|||
*/
|
||||
private List<Status> cursorToListStatuses(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
List<Status> statuses = new ArrayList<>();
|
||||
while (c.moveToNext() ) {
|
||||
//Restore cached status
|
||||
|
@ -787,8 +801,10 @@ public class StatusCacheDAO {
|
|||
*/
|
||||
private List<String> cursorToListStatusesId(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
List<String> statusesId = new ArrayList<>();
|
||||
while (c.moveToNext() ) {
|
||||
//Restore cached status
|
||||
|
|
|
@ -296,8 +296,10 @@ public class StatusStoredDAO {
|
|||
*/
|
||||
private StoredStatus cursorToStoredStatus(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
//Take the first element
|
||||
c.moveToFirst();
|
||||
//New user
|
||||
|
@ -331,8 +333,10 @@ public class StatusStoredDAO {
|
|||
*/
|
||||
private List<StoredStatus> cursorToListStatuses(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
List<StoredStatus> storedStatuses = new ArrayList<>();
|
||||
while (c.moveToNext() ) {
|
||||
//Restore the status
|
||||
|
|
|
@ -118,8 +118,10 @@ public class TagsCacheDAO {
|
|||
*/
|
||||
private List<String> cursorToTag(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
List<String> tags = new ArrayList<>();
|
||||
while (c.moveToNext() ) {
|
||||
tags.add(c.getString(c.getColumnIndex(Sqlite.COL_TAGS)));
|
||||
|
|
|
@ -154,8 +154,10 @@ public class TempMuteDAO {
|
|||
*/
|
||||
private String cursorToDate(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
c.moveToNext();
|
||||
String date = c.getString(c.getColumnIndex(Sqlite.COL_DATE_END));
|
||||
//Close the cursor
|
||||
|
|
|
@ -160,8 +160,10 @@ public class TimelinesDAO {
|
|||
*/
|
||||
private ManageTimelines cursorToTimeline(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
//Take the first element
|
||||
c.moveToFirst();
|
||||
//New timeline
|
||||
|
@ -190,8 +192,10 @@ public class TimelinesDAO {
|
|||
*/
|
||||
private List<ManageTimelines> cursorToTimelines(Cursor c){
|
||||
//No element found
|
||||
if (c.getCount() == 0)
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
List<ManageTimelines> remoteInstances = new ArrayList<>();
|
||||
while (c.moveToNext() ) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue