Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ 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: Avoid npe caused by `isEmpty()` check on a null shopping cart
* ui: Change project reference in `ProductResolver.kt` to get rid of IllegalArgumentException

## [0.72.4]
### Added
Expand Down
8 changes: 3 additions & 5 deletions ui/src/main/java/io/snabble/sdk/ui/scanner/ProductResolver.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private void updateCartButton() {
}

public void lookupAndShowProduct(List<ScannedCode> scannedCodes, BarcodeFormat barcodeFormat) {
new ProductResolver.Builder(getContext())
new ProductResolver.Builder(getContext(), project)
.setCodes(scannedCodes)
.setBarcodeFormat(barcodeFormat)
.setOnShowListener(this::pauseBarcodeScanner)
Expand Down