1
0
mirror of https://github.com/etesync/android synced 2024-12-24 15:38:09 +00:00

Calendar sync adapter service: minor cleanup.

This commit is contained in:
Tom Hacohen 2017-04-05 18:56:33 +01:00
parent b6f97ac955
commit 0a4d4a9d9e

View File

@ -72,7 +72,9 @@ public class CalendarsSyncAdapterService extends SyncAdapterService {
new RefreshCollections(account, CollectionInfo.Type.CALENDAR).run(); new RefreshCollections(account, CollectionInfo.Type.CALENDAR).run();
HttpUrl principal = updateLocalCalendars(provider, account, settings); updateLocalCalendars(provider, account, settings);
HttpUrl principal = HttpUrl.get(settings.getUri());
for (LocalCalendar calendar : (LocalCalendar[]) LocalCalendar.find(account, provider, LocalCalendar.Factory.INSTANCE, CalendarContract.Calendars.SYNC_EVENTS + "!=0", null)) { for (LocalCalendar calendar : (LocalCalendar[]) LocalCalendar.find(account, provider, LocalCalendar.Factory.INSTANCE, CalendarContract.Calendars.SYNC_EVENTS + "!=0", null)) {
App.log.info("Synchronizing calendar #" + calendar.getId() + ", URL: " + calendar.getName()); App.log.info("Synchronizing calendar #" + calendar.getId() + ", URL: " + calendar.getName());
@ -106,16 +108,13 @@ public class CalendarsSyncAdapterService extends SyncAdapterService {
App.log.info("Calendar sync complete"); App.log.info("Calendar sync complete");
} }
private HttpUrl updateLocalCalendars(ContentProviderClient provider, Account account, AccountSettings settings) throws CalendarStorageException { private void updateLocalCalendars(ContentProviderClient provider, Account account, AccountSettings settings) throws CalendarStorageException {
HttpUrl ret = null;
ServiceDB.OpenHelper dbHelper = new ServiceDB.OpenHelper(getContext()); ServiceDB.OpenHelper dbHelper = new ServiceDB.OpenHelper(getContext());
try { try {
// enumerate remote and local calendars // enumerate remote and local calendars
SQLiteDatabase db = dbHelper.getReadableDatabase(); SQLiteDatabase db = dbHelper.getReadableDatabase();
Long service = dbHelper.getService(db, account, Services.SERVICE_CALDAV); Long service = dbHelper.getService(db, account, Services.SERVICE_CALDAV);
ret = HttpUrl.get(settings.getUri());
EntityDataStore<Persistable> data = ((App) getContext().getApplicationContext()).getData(); EntityDataStore<Persistable> data = ((App) getContext().getApplicationContext()).getData();
Map<String, CollectionInfo> remote = new HashMap<>(); Map<String, CollectionInfo> remote = new HashMap<>();
List<CollectionInfo> remoteCollections = JournalEntity.getCollections(data, service); List<CollectionInfo> remoteCollections = JournalEntity.getCollections(data, service);
@ -152,8 +151,6 @@ public class CalendarsSyncAdapterService extends SyncAdapterService {
} finally { } finally {
dbHelper.close(); dbHelper.close();
} }
return ret;
} }
} }