diff options
author | Stefan Niedermann <info@niedermann.it> | 2022-07-09 23:41:01 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2022-07-09 23:41:01 +0300 |
commit | 712c7f797b01c563928c37d2f832b4c5d171b32f (patch) | |
tree | 25a0cfcd22eadfbbd92ae1de3461460edb89e2c5 /app/src/main/java/it/niedermann/nextcloud/deck/ui | |
parent | d78e4fa2ffe7d294fc1be723814251cf08613ca3 (diff) |
Fix #1295 🐞 Handle offline card creation better
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/card/NewCardDialog.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/NewCardDialog.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/NewCardDialog.java index 6d6a5434d..49daf2b32 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/NewCardDialog.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/NewCardDialog.java @@ -14,6 +14,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; +import android.widget.Toast; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; @@ -26,6 +27,7 @@ import androidx.lifecycle.ViewModelProvider; import it.niedermann.nextcloud.deck.R; import it.niedermann.nextcloud.deck.api.IResponseCallback; import it.niedermann.nextcloud.deck.databinding.DialogNewCardBinding; +import it.niedermann.nextcloud.deck.exceptions.OfflineException; import it.niedermann.nextcloud.deck.model.Account; import it.niedermann.nextcloud.deck.model.full.FullCard; import it.niedermann.nextcloud.deck.ui.branding.BrandingUtil; @@ -59,7 +61,7 @@ public class NewCardDialog extends DialogFragment implements DialogInterface.OnC if (context instanceof CreateCardListener) { this.createCardListener = (CreateCardListener) context; } else { - throw new ClassCastException("Caller must implement " + CreateCardListener.class.getCanonicalName()); + throw new ClassCastException("Caller must implement " + CreateCardListener.class.getCanonicalName()); } final var args = getArguments(); @@ -195,9 +197,13 @@ public class NewCardDialog extends DialogFragment implements DialogInterface.OnC IResponseCallback.super.onError(throwable); requireActivity().runOnUiThread(() -> { isPending.setValue(false); - ExceptionDialogFragment - .newInstance(throwable, account) - .show(getChildFragmentManager(), ExceptionDialogFragment.class.getSimpleName()); + if (throwable instanceof OfflineException) { + Toast.makeText(requireContext(), ((OfflineException) throwable).getReason().getMessage(), Toast.LENGTH_LONG).show(); + } else { + ExceptionDialogFragment + .newInstance(throwable, account) + .show(getChildFragmentManager(), ExceptionDialogFragment.class.getSimpleName()); + } }); } }); |