From dd6ce617cc1ccce6abc109337623a50e68178178 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 16 Feb 2017 19:22:40 +0000 Subject: [PATCH] Remove the redundant collection getAll() function. We aren't using it, and shouldn't be using it. It's very inefficient, and doesn't help what we want to do. --- .../davdroid/resource/LocalAddressBook.java | 14 ++------------ .../bitfire/davdroid/resource/LocalCalendar.java | 6 ------ .../bitfire/davdroid/resource/LocalCollection.java | 1 - .../bitfire/davdroid/resource/LocalTaskList.java | 6 ------ 4 files changed, 2 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java b/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java index e63e714c..1ea59cc8 100644 --- a/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java +++ b/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java @@ -49,7 +49,7 @@ public class LocalAddressBook extends AndroidAddressBook implements LocalCollect /** * Whether contact groups (LocalGroup resources) are included in query results for - * {@link #getAll()}, {@link #getDeleted()}, {@link #getDirty()} and + * {@link #getDeleted()}, {@link #getDirty()} and * {@link #getWithoutFileName()}. */ public boolean includeGroups = true; @@ -61,22 +61,12 @@ public class LocalAddressBook extends AndroidAddressBook implements LocalCollect @NonNull public LocalContact findContactByUID(String uid) throws ContactsStorageException, FileNotFoundException { - LocalContact[] contacts = (LocalContact[])queryContacts(LocalContact.COLUMN_UID + "=?", new String[] { uid }); + LocalContact[] contacts = (LocalContact[]) queryContacts(LocalContact.COLUMN_UID + "=?", new String[]{uid}); if (contacts.length == 0) throw new FileNotFoundException(); return contacts[0]; } - @Override - @NonNull - public LocalResource[] getAll() throws ContactsStorageException { - List all = new LinkedList<>(); - Collections.addAll(all, (LocalResource[])queryContacts(null, null)); - if (includeGroups) - Collections.addAll(all, (LocalResource[])queryGroups(null, null)); - return all.toArray(new LocalResource[all.size()]); - } - /** * Returns an array of local contacts/groups which have been deleted locally. (DELETED != 0). */ diff --git a/app/src/main/java/at/bitfire/davdroid/resource/LocalCalendar.java b/app/src/main/java/at/bitfire/davdroid/resource/LocalCalendar.java index d70fbc44..d645508d 100644 --- a/app/src/main/java/at/bitfire/davdroid/resource/LocalCalendar.java +++ b/app/src/main/java/at/bitfire/davdroid/resource/LocalCalendar.java @@ -109,12 +109,6 @@ public class LocalCalendar extends AndroidCalendar implements LocalCollection { return values; } - - @Override - public LocalResource[] getAll() throws CalendarStorageException, ContactsStorageException { - return (LocalEvent[])queryEvents(Events.ORIGINAL_ID + " IS NULL", null); - } - @Override public LocalEvent[] getDeleted() throws CalendarStorageException { return (LocalEvent[])queryEvents(Events.DELETED + "!=0 AND " + Events.ORIGINAL_ID + " IS NULL", null); diff --git a/app/src/main/java/at/bitfire/davdroid/resource/LocalCollection.java b/app/src/main/java/at/bitfire/davdroid/resource/LocalCollection.java index 4b43d073..1a73e98c 100644 --- a/app/src/main/java/at/bitfire/davdroid/resource/LocalCollection.java +++ b/app/src/main/java/at/bitfire/davdroid/resource/LocalCollection.java @@ -20,7 +20,6 @@ public interface LocalCollection { /** Dirty *non-deleted* entries */ LocalResource[] getDirty() throws CalendarStorageException, ContactsStorageException, FileNotFoundException; - LocalResource[] getAll() throws CalendarStorageException, ContactsStorageException; LocalResource getByUid(String uid) throws CalendarStorageException, ContactsStorageException; String getCTag() throws CalendarStorageException, ContactsStorageException; diff --git a/app/src/main/java/at/bitfire/davdroid/resource/LocalTaskList.java b/app/src/main/java/at/bitfire/davdroid/resource/LocalTaskList.java index 6755a34a..382505cd 100644 --- a/app/src/main/java/at/bitfire/davdroid/resource/LocalTaskList.java +++ b/app/src/main/java/at/bitfire/davdroid/resource/LocalTaskList.java @@ -78,12 +78,6 @@ public class LocalTaskList extends AndroidTaskList implements LocalCollection { return values; } - - @Override - public LocalTask[] getAll() throws CalendarStorageException { - return (LocalTask[])queryTasks(null, null); - } - @Override public LocalTask[] getDeleted() throws CalendarStorageException { return (LocalTask[])queryTasks(Tasks._DELETED + "!=0", null);