From cd54581320bd0ae410951aae6fb551c3a5284638 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 14 Feb 2024 09:57:04 +0100 Subject: [PATCH] Fix tests Signed-off-by: alperozturk --- .../java/com/nextcloud/utils/extensions/BundleExtensions.kt | 6 +++++- .../java/com/nextcloud/utils/extensions/IntentExtensions.kt | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/utils/extensions/BundleExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/BundleExtensions.kt index 7b4c471738..67e86f3ea6 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/BundleExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/BundleExtensions.kt @@ -40,7 +40,11 @@ fun Bundle?.getSerializableArgument(key: String, type: Class this.getSerializable(key, type) } else { @Suppress("UNCHECKED_CAST", "DEPRECATION") - this.getSerializable(key) as T + if (type.isInstance(this.getSerializable(key))) { + this.getSerializable(key) as T + } else { + null + } } } catch (e: ClassCastException) { Log_OC.e(tag, e.localizedMessage) diff --git a/app/src/main/java/com/nextcloud/utils/extensions/IntentExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/IntentExtensions.kt index f52ddeffb5..30789ba423 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/IntentExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/IntentExtensions.kt @@ -40,7 +40,11 @@ fun Intent?.getSerializableArgument(key: String, type: Class this.getSerializableExtra(key, type) } else { @Suppress("UNCHECKED_CAST", "DEPRECATION") - this.getSerializableExtra(key) as T + if (type.isInstance(this.getSerializableExtra(key))) { + this.getSerializableExtra(key) as T + } else { + null + } } } catch (e: ClassCastException) { Log_OC.e(tag, e.localizedMessage)