diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-05-17 20:48:37 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-05-17 20:48:37 +0300 |
commit | af4058f30e9e35ebdc1f26109c63ca94005ffb3b (patch) | |
tree | bf69e6d87b3ee5a1f8a5c76d8ddf704a11db7a10 /app/src/main | |
parent | 099f13af21c1280376cf00308e192a26f428d669 (diff) |
Fix maintenance mode crash1.4.2
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java | 93 |
1 files changed, 49 insertions, 44 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java index ee4a3119b..265015d57 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java @@ -158,59 +158,64 @@ public class SyncManager { doAsync(() -> refreshCapabilities(new IResponseCallback<Capabilities>(responseCallback.getAccount()) { @Override public void onResponse(Capabilities response) { - if (!response.isMaintenanceEnabled() && response.getDeckVersion().isSupported(appContext)) { - long accountId = responseCallback.getAccount().getId(); - Date lastSyncDate = LastSyncUtil.getLastSyncDate(responseCallback.getAccount().getId()); - Date now = DateUtil.nowInGMT(); + if (!response.isMaintenanceEnabled()) { + if (response.getDeckVersion().isSupported(appContext)) { + long accountId = responseCallback.getAccount().getId(); + Date lastSyncDate = LastSyncUtil.getLastSyncDate(responseCallback.getAccount().getId()); + Date now = DateUtil.nowInGMT(); - final SyncHelper syncHelper = new SyncHelper(serverAdapter, dataBaseAdapter, lastSyncDate); + final SyncHelper syncHelper = new SyncHelper(serverAdapter, dataBaseAdapter, lastSyncDate); - IResponseCallback<Boolean> callback = new IResponseCallback<Boolean>(responseCallback.getAccount()) { - @Override - public void onResponse(Boolean response) { - syncHelper.setResponseCallback(new IResponseCallback<Boolean>(account) { - @Override - public void onResponse(Boolean response) { - // TODO deactivate for dev - LastSyncUtil.setLastSyncDate(accountId, now); - responseCallback.onResponse(response); - } - - @Override - public void onError(Throwable throwable) { - super.onError(throwable); - responseCallback.onError(throwable); - } - }); - doAsync(() -> { - try { - syncHelper.doUpSyncFor(new BoardDataProvider()); - } catch (Throwable e) { - DeckLog.logError(e); - responseCallback.onError(e); - } - }); + IResponseCallback<Boolean> callback = new IResponseCallback<Boolean>(responseCallback.getAccount()) { + @Override + public void onResponse(Boolean response) { + syncHelper.setResponseCallback(new IResponseCallback<Boolean>(account) { + @Override + public void onResponse(Boolean response) { + // TODO deactivate for dev + LastSyncUtil.setLastSyncDate(accountId, now); + responseCallback.onResponse(response); + } + + @Override + public void onError(Throwable throwable) { + super.onError(throwable); + responseCallback.onError(throwable); + } + }); + doAsync(() -> { + try { + syncHelper.doUpSyncFor(new BoardDataProvider()); + } catch (Throwable e) { + DeckLog.logError(e); + responseCallback.onError(e); + } + }); - } + } - @Override - public void onError(Throwable throwable) { - super.onError(throwable); - responseCallback.onError(throwable); - } - }; + @Override + public void onError(Throwable throwable) { + super.onError(throwable); + responseCallback.onError(throwable); + } + }; - syncHelper.setResponseCallback(callback); + syncHelper.setResponseCallback(callback); - try { - syncHelper.doSyncFor(new BoardDataProvider()); - } catch (Throwable e) { - DeckLog.logError(e); - responseCallback.onError(e); + try { + syncHelper.doSyncFor(new BoardDataProvider()); + } catch (Throwable e) { + DeckLog.logError(e); + responseCallback.onError(e); + } + } else { + responseCallback.onResponse(false); + DeckLog.warn("No sync. Server version not supported: " + response.getDeckVersion().getOriginalVersion()); } } else { responseCallback.onResponse(false); - DeckLog.warn("No sync. Status maintenance mode: " + response.isMaintenanceEnabled() + ". Server version : " + response.getDeckVersion().getOriginalVersion()); + DeckLog.warn("No sync. Status maintenance mode: " + response.isMaintenanceEnabled()); } } })); |