Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2021-04-19 10:06:05 +0300
committerStefan Niedermann <info@niedermann.it>2021-04-19 10:06:05 +0300
commit0831e0100534ebe4777ed187d354167a77a4f1ca (patch)
tree077b1137d4004e5548ad5f048990932f94104d93 /app/src/main/java/it/niedermann/nextcloud/deck/ui
parentce5c4ea90bf439c81cbaffde0b6eabab8d9bf39d (diff)
#680 Loading indicator is shown indefinitely and no synchronization
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java60
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java4
2 files changed, 39 insertions, 25 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java
index 80ae13790..7ef065e35 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java
@@ -264,7 +264,7 @@ public class MainActivity extends AppCompatActivity implements DeleteStackListen
saveCurrentAccount(this, mainViewModel.getCurrentAccount());
if (mainViewModel.getCurrentAccount().isMaintenanceEnabled()) {
- refreshCapabilities(mainViewModel.getCurrentAccount());
+ refreshCapabilities(mainViewModel.getCurrentAccount(), null);
}
lastBoardId = readCurrentBoardId(this, mainViewModel.getCurrentAccount().getId());
@@ -407,23 +407,23 @@ public class MainActivity extends AppCompatActivity implements DeleteStackListen
CustomAppGlideModule.clearCache(this);
DeckLog.verbose("Trigger refresh capabilities for", mainViewModel.getCurrentAccount().getName());
- refreshCapabilities(mainViewModel.getCurrentAccount());
-
- DeckLog.verbose("Trigger synchronization for", mainViewModel.getCurrentAccount().getName());
- mainViewModel.synchronize(new IResponseCallback<Boolean>(mainViewModel.getCurrentAccount()) {
- @Override
- public void onResponse(Boolean response) {
- DeckLog.info("End of synchronization for " + mainViewModel.getCurrentAccount().getName() + " → Stop spinner.");
- runOnUiThread(() -> binding.swipeRefreshLayout.setRefreshing(false));
- }
+ refreshCapabilities(mainViewModel.getCurrentAccount(), () -> {
+ DeckLog.verbose("Trigger synchronization for", mainViewModel.getCurrentAccount().getName());
+ mainViewModel.synchronize(new IResponseCallback<Boolean>(mainViewModel.getCurrentAccount()) {
+ @Override
+ public void onResponse(Boolean response) {
+ DeckLog.info("End of synchronization for " + mainViewModel.getCurrentAccount().getName() + " → Stop spinner.");
+ runOnUiThread(() -> binding.swipeRefreshLayout.setRefreshing(false));
+ }
- @Override
- public void onError(Throwable throwable) {
- super.onError(throwable);
- DeckLog.info("End of synchronization for " + mainViewModel.getCurrentAccount().getName() + " → Stop spinner.");
- showSyncFailedSnackbar(throwable);
- runOnUiThread(() -> binding.swipeRefreshLayout.setRefreshing(false));
- }
+ @Override
+ public void onError(Throwable throwable) {
+ super.onError(throwable);
+ DeckLog.info("End of synchronization for " + mainViewModel.getCurrentAccount().getName() + " → Stop spinner.");
+ showSyncFailedSnackbar(throwable);
+ runOnUiThread(() -> binding.swipeRefreshLayout.setRefreshing(false));
+ }
+ });
});
});
});
@@ -538,34 +538,40 @@ public class MainActivity extends AppCompatActivity implements DeleteStackListen
});
}
- private void refreshCapabilities(final Account account) {
+ private void refreshCapabilities(final Account account, @Nullable Runnable runAfter) {
DeckLog.verbose("Refreshing capabilities for", account.getName());
mainViewModel.refreshCapabilities(new IResponseCallback<Capabilities>(account) {
@Override
public void onResponse(Capabilities response) {
DeckLog.verbose("Finished refreshing capabilities for", account.getName(), "successfully.");
if (response.isMaintenanceEnabled()) {
- DeckLog.verbose("Maintenance mode is enabled → Stop spinner.");
- binding.swipeRefreshLayout.setRefreshing(false);
+ DeckLog.verbose("Maintenance mode is enabled.");
} else {
- DeckLog.verbose("Maintenance mode is disabled → Stop spinner.");
+ DeckLog.verbose("Maintenance mode is disabled.");
// If we notice after updating the capabilities, that the new version is not supported, but it was previously, recreate the activity to make sure all elements are disabled properly
if (mainViewModel.getCurrentAccount().getServerDeckVersionAsObject().isSupported() && !response.getDeckVersion().isSupported()) {
ActivityCompat.recreate(MainActivity.this);
}
}
+
+ if (runAfter != null) {
+ runAfter.run();
+ }
}
@Override
public void onError(Throwable throwable) {
- DeckLog.warn("Error on refreshing capabilities for", account.getName(), "(" + throwable.getMessage() + ") → Stop spinner.");
- binding.swipeRefreshLayout.setRefreshing(false);
- if (throwable instanceof OfflineException) {
+ DeckLog.warn("Error on refreshing capabilities for", account.getName(), "(" + throwable.getMessage() + ").");
+ if (throwable.getClass() == OfflineException.class || throwable instanceof OfflineException) {
DeckLog.info("Cannot refresh capabilities because device is offline.");
} else {
super.onError(throwable);
ExceptionDialogFragment.newInstance(throwable, account).show(getSupportFragmentManager(), ExceptionDialogFragment.class.getSimpleName());
}
+
+ if (runAfter != null) {
+ runAfter.run();
+ }
}
});
}
@@ -972,7 +978,11 @@ public class MainActivity extends AppCompatActivity implements DeleteStackListen
@Override
public void onError(Throwable throwable) {
super.onError(throwable);
- showSyncFailedSnackbar(throwable);
+ if (throwable.getClass() == OfflineException.class || throwable instanceof OfflineException) {
+ DeckLog.error("Do not show synchronization failed snackbar because it is an ", OfflineException.class.getSimpleName(), "- assuming the user has wi-fi disabled but \"Sync only on wi-fi\" enabled");
+ } else {
+ showSyncFailedSnackbar(throwable);
+ }
}
});
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java
index b87cee5f9..3117a4650 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/exception/tips/TipsAdapter.java
@@ -33,6 +33,7 @@ import java.util.List;
import it.niedermann.nextcloud.deck.BuildConfig;
import it.niedermann.nextcloud.deck.R;
import it.niedermann.nextcloud.deck.exceptions.DeckException;
+import it.niedermann.nextcloud.deck.exceptions.OfflineException;
import it.niedermann.nextcloud.deck.exceptions.UploadAttachmentFailedException;
import it.niedermann.nextcloud.deck.model.Account;
@@ -79,6 +80,9 @@ public class TipsAdapter extends RecyclerView.Adapter<TipsViewHolder> {
add(R.string.error_dialog_tip_clear_storage, INTENT_APP_INFO);
} else if (throwable instanceof NextcloudFilesAppNotSupportedException) {
add(R.string.error_dialog_tip_files_outdated);
+ } else if (throwable instanceof OfflineException) {
+ add(R.string.error_dialog_tip_offline);
+ add(R.string.error_dialog_tip_sync_only_on_wifi);
} else if (throwable instanceof NextcloudApiNotRespondingException) {
if (VERSION.SDK_INT >= VERSION_CODES.M) {
add(R.string.error_dialog_tip_disable_battery_optimizations, new Intent().setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS).putExtra(INTENT_EXTRA_BUTTON_TEXT, R.string.error_action_open_battery_settings));