Skip to content

Commit b804b39

Browse files
authored
Refactored fix for null cart app crash (#93)
The cart is now again only set on adapter creation, but the adapter is created and set after a project checkin/change.
1 parent 5246db4 commit b804b39

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
55
### Added
66
* Added payment method PAYONE SEPA
77

8+
### Changed
9+
* Set the cart adapter after a project change (different fix for the same bug from #90)
10+
811
## [0.69.1-beta07]
912
### Fixed
1013
* Fixed navigation when using manual product search

ui/src/main/java/io/snabble/sdk/ui/cart/ShoppingCartView.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,6 @@ public int getItemCount() {
626626

627627
// for fetching the data from outside of this view
628628
public void fetchFrom(ShoppingCart cart) {
629-
this.cart = cart;
630-
631629
hasAnyImages = false;
632630

633631
for (int i = 0; i < cart.size(); i++) {

ui/src/main/java/io/snabble/sdk/ui/scanner/CombinedScannerFragment.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class CombinedScannerFragment : SelfScanningFragment() {
8888
Snabble.checkedInProject.observe(viewLifecycleOwner) { project ->
8989
project?.let {
9090
scannerBottomSheetView.cart = it.shoppingCart
91+
92+
val cartAdapter = ShoppingCartView.ShoppingCartAdapter(scannerBottomSheetView, it.shoppingCart)
93+
scannerBottomSheetView.shoppingCartAdapter = cartAdapter
9194
}
9295
}
9396
scannerBottomSheetView.behavior = ScannerBottomSheetBehavior(scannerBottomSheetView).apply {
@@ -118,9 +121,6 @@ class CombinedScannerFragment : SelfScanningFragment() {
118121
}
119122
}
120123

121-
val cartAdapter = ShoppingCartView.ShoppingCartAdapter(scannerBottomSheetView, cart)
122-
123-
scannerBottomSheetView.shoppingCartAdapter = cartAdapter
124124
scannerBottomSheetView.onItemsChangedListener += ::cartChanged
125125
createItemTouchHelper()
126126
}

0 commit comments

Comments
 (0)