From b1aea4f127e9371ff51b49d4ef6db0d0922f0148 Mon Sep 17 00:00:00 2001 From: Fabian Bender Date: Tue, 20 Feb 2024 08:49:59 +0100 Subject: [PATCH 1/3] change reference of project to the constructor param instead of using the deprecated version from `SnabbleUI`. Also remove default value for the project in Builder function to avoid further IllegalArgumentException --- .../java/io/snabble/sdk/ui/scanner/ProductResolver.kt | 8 +++----- .../java/io/snabble/sdk/ui/scanner/SelfScanningView.java | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ui/src/main/java/io/snabble/sdk/ui/scanner/ProductResolver.kt b/ui/src/main/java/io/snabble/sdk/ui/scanner/ProductResolver.kt index 8dd7645283..10416a1b09 100644 --- a/ui/src/main/java/io/snabble/sdk/ui/scanner/ProductResolver.kt +++ b/ui/src/main/java/io/snabble/sdk/ui/scanner/ProductResolver.kt @@ -1,6 +1,5 @@ package io.snabble.sdk.ui.scanner -import android.app.ProgressDialog import android.content.Context import android.content.DialogInterface import android.view.KeyEvent @@ -9,7 +8,6 @@ import io.snabble.sdk.Unit import io.snabble.sdk.codes.ScannedCode import io.snabble.sdk.codes.gs1.GS1Code import io.snabble.sdk.ui.R -import io.snabble.sdk.ui.SnabbleUI import io.snabble.sdk.ui.scanner.ProductResolver.* import io.snabble.sdk.ui.telemetry.Telemetry import io.snabble.sdk.ui.utils.DelayedProgressDialog @@ -283,7 +281,7 @@ class ProductResolver private constructor(private val context: Context, private if (product != null && scannedCode != null) { if (handleProductFlags(product, scannedCode)) { - val model = ProductConfirmationDialog.ViewModel(context, SnabbleUI.project, product, scannedCode) + val model = ProductConfirmationDialog.ViewModel(context, project, product, scannedCode) productDialogViewModel = model productConfirmationDialog?.show(UIUtils.getHostFragmentActivity(context), model) } @@ -459,9 +457,9 @@ class ProductResolver private constructor(private val context: Context, private * @param context The context for the product resolver * @param project The optional project of the product resolver, by default the current project will be used */ - class Builder @JvmOverloads constructor( + class Builder( context: Context, - private val project: Project = requireNotNull(Snabble.checkedInProject.value) + private val project: Project ) { private val productResolver = ProductResolver(context, project) private var factory = ProductConfirmationDialog.Factory { diff --git a/ui/src/main/java/io/snabble/sdk/ui/scanner/SelfScanningView.java b/ui/src/main/java/io/snabble/sdk/ui/scanner/SelfScanningView.java index 831406e89f..23d22c5fcd 100644 --- a/ui/src/main/java/io/snabble/sdk/ui/scanner/SelfScanningView.java +++ b/ui/src/main/java/io/snabble/sdk/ui/scanner/SelfScanningView.java @@ -179,7 +179,7 @@ private void updateCartButton() { } public void lookupAndShowProduct(List scannedCodes, BarcodeFormat barcodeFormat) { - new ProductResolver.Builder(getContext()) + new ProductResolver.Builder(getContext(), project) .setCodes(scannedCodes) .setBarcodeFormat(barcodeFormat) .setOnShowListener(this::pauseBarcodeScanner) From f1dbd600bbf7724e8088a8b0bc99b79a08f8e625 Mon Sep 17 00:00:00 2001 From: Fabian Bender Date: Tue, 20 Feb 2024 08:54:12 +0100 Subject: [PATCH 2/3] change CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3c12228cc..06a909d058 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ### Changed ### Removed ### Fixed +ui: change project reference in `ProductResolver.kt` to get rid of IllegalArgumentException ## [0.72.4] ### Added From 0ac92f12200b850def773f945cc3a8ca04ea4b11 Mon Sep 17 00:00:00 2001 From: Fabian Bender Date: Tue, 20 Feb 2024 09:06:27 +0100 Subject: [PATCH 3/3] add change notes since the use of the `ProductResolver.Builder` changed --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06a909d058..abd59c40d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. ## UNRELEASED ### Added ### Changed +ui: the `ProductResolver.Builder` now requires a project as constructor param, since the default value has been removed ### Removed ### Fixed ui: change project reference in `ProductResolver.kt` to get rid of IllegalArgumentException