From 1e597f583a14e460c0652b990dfa4df8b3c42da4 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Mon, 9 Apr 2018 10:00:52 -0500 Subject: [PATCH] Return null calendar list on error --- .../java/org/tasks/caldav/CaldavClient.java | 17 +---------------- .../org/tasks/caldav/CaldavSynchronizer.java | 3 +++ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/tasks/caldav/CaldavClient.java b/app/src/main/java/org/tasks/caldav/CaldavClient.java index 208d9e000..12ae5e940 100644 --- a/app/src/main/java/org/tasks/caldav/CaldavClient.java +++ b/app/src/main/java/org/tasks/caldav/CaldavClient.java @@ -127,7 +127,7 @@ class CaldavClient { 1, ResourceType.NAME, DisplayName.NAME, SupportedCalendarComponentSet.NAME, GetCTag.NAME); } catch (IOException | HttpException | DavException e) { Timber.e(e); - return emptyList(); + return null; } List urls = new ArrayList<>(); for (DavResource member : davResource.getMembers()) { @@ -152,19 +152,4 @@ class CaldavClient { } return urls; } - - public Single getDisplayName() { - Callable callable = - () -> { - davResource.propfind(0, DisplayName.NAME); - DisplayName displayName = davResource.getProperties().get(DisplayName.class); - if (displayName == null) { - throw new DisplayableException(R.string.calendar_not_found); - } - return displayName.getDisplayName(); - }; - return Single.fromCallable(callable) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()); - } } diff --git a/app/src/main/java/org/tasks/caldav/CaldavSynchronizer.java b/app/src/main/java/org/tasks/caldav/CaldavSynchronizer.java index 273d1fe59..d16ecb4ec 100644 --- a/app/src/main/java/org/tasks/caldav/CaldavSynchronizer.java +++ b/app/src/main/java/org/tasks/caldav/CaldavSynchronizer.java @@ -102,6 +102,9 @@ public class CaldavSynchronizer { } CaldavClient caldavClient = new CaldavClient(account, encryption); List resources = caldavClient.getCalendars(); + if (resources == null) { + continue; + } Set urls = newHashSet(transform(resources, c -> c.getLocation().toString())); Timber.d("Found calendars: %s", urls); for (CaldavCalendar deleted :