From 1e0821588d1392e47a586956457e3842bac9f260 Mon Sep 17 00:00:00 2001 From: desperateCoder Date: Fri, 29 Nov 2024 21:28:24 +0100 Subject: [PATCH] #1657 sync issues: fix npe --- .../niedermann/nextcloud/deck/remote/helpers/SyncHelper.java | 3 +-- .../helpers/providers/CardLabelRelationshipProvider.java | 4 ++-- .../helpers/providers/CardUserRelationshipProvider.java | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/remote/helpers/SyncHelper.java b/app/src/main/java/it/niedermann/nextcloud/deck/remote/helpers/SyncHelper.java index 0398dd908..376e22bac 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/remote/helpers/SyncHelper.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/remote/helpers/SyncHelper.java @@ -26,7 +26,6 @@ import it.niedermann.nextcloud.deck.remote.api.ResponseCallback; import it.niedermann.nextcloud.deck.remote.helpers.providers.AbstractSyncDataProvider; import it.niedermann.nextcloud.deck.remote.helpers.providers.IRelationshipProvider; -import it.niedermann.nextcloud.deck.util.ExecutorServiceProvider; import okhttp3.Headers; public class SyncHelper { @@ -77,7 +76,7 @@ public void onResponse(List response, Headers headers) { if (existingEntity == null) { try { - ExecutorServiceProvider.awaitExecution(() -> provider.createInDB(dataBaseAdapter, accountId, entityFromServer)); + provider.createInDB(dataBaseAdapter, accountId, entityFromServer); } catch (SQLiteConstraintException e) { provider.onInsertFailed(dataBaseAdapter, e, account, accountId, response, entityFromServer); throw new RuntimeException("ConstraintViolation! Entity: " + provider.getClass().getSimpleName()+"\n" diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/remote/helpers/providers/CardLabelRelationshipProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/remote/helpers/providers/CardLabelRelationshipProvider.java index f3157bd58..db1fcfc61 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/remote/helpers/providers/CardLabelRelationshipProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/remote/helpers/providers/CardLabelRelationshipProvider.java @@ -23,7 +23,7 @@ public void insertAllNecessary(DataBaseAdapter dataBaseAdapter, long accountId) if (labels== null){ return; } - Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId()); +// Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId()); for (Label label : labels) { Label existingLabel = dataBaseAdapter.getLabelByRemoteIdDirectly(accountId, label.getId()); if (existingLabel != null) { // maybe not synced yet, skipping this time. next sync will be able to push it up @@ -37,7 +37,7 @@ public void insertAllNecessary(DataBaseAdapter dataBaseAdapter, long accountId) @Override public void deleteAllExisting(DataBaseAdapter dataBaseAdapter, long accountId) { - Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId()); +// Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId()); dataBaseAdapter.deleteJoinedLabelsForCard(card.getLocalId()); } } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/remote/helpers/providers/CardUserRelationshipProvider.java b/app/src/main/java/it/niedermann/nextcloud/deck/remote/helpers/providers/CardUserRelationshipProvider.java index ece44c463..405f0b6c0 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/remote/helpers/providers/CardUserRelationshipProvider.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/remote/helpers/providers/CardUserRelationshipProvider.java @@ -22,7 +22,7 @@ public void insertAllNecessary(DataBaseAdapter dataBaseAdapter, long accountId) if (users == null){ return; } - Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId()); +// Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId()); for (User user : users){ User existingUser = dataBaseAdapter.getUserByUidDirectly(accountId, user.getUid()); JoinCardWithUser existingJoin = dataBaseAdapter.getJoinCardWithUser(existingUser.getLocalId(), card.getLocalId()); @@ -34,7 +34,7 @@ public void insertAllNecessary(DataBaseAdapter dataBaseAdapter, long accountId) @Override public void deleteAllExisting(DataBaseAdapter dataBaseAdapter, long accountId) { - Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId()); +// Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId()); dataBaseAdapter.deleteJoinedUsersForCard(card.getLocalId()); } }