Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HCI Android Templ
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabio-Andre Heyming
HCI Android Templ
Commits
56ca5cbc
Commit
56ca5cbc
authored
1 year ago
by
Fabio Heyming
Browse files
Options
Downloads
Patches
Plain Diff
Added persistant shopping cart
parent
a2960b1c
No related branches found
No related tags found
1 merge request
!1
Mal aufn Master megren
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/com/example/mampfmobil/ui/MampfMobil.java
+47
-5
47 additions, 5 deletions
app/src/main/java/com/example/mampfmobil/ui/MampfMobil.java
with
47 additions
and
5 deletions
app/src/main/java/com/example/mampfmobil/ui/MampfMobil.java
+
47
−
5
View file @
56ca5cbc
...
@@ -283,7 +283,7 @@ public class MampfMobil {
...
@@ -283,7 +283,7 @@ public class MampfMobil {
//
bestellungsteil besteht aus
Customer-ID, ShopItem-ID
//Customer-ID, ShopItem-ID
String
csvFavoriten
=
""
;
String
csvFavoriten
=
""
;
for
(
Customer
c:
MampfMobil
.
customers
){
for
(
Customer
c:
MampfMobil
.
customers
){
for
(
ShopItem
sI:
c
.
favoriten
){
for
(
ShopItem
sI:
c
.
favoriten
){
...
@@ -291,7 +291,18 @@ public class MampfMobil {
...
@@ -291,7 +291,18 @@ public class MampfMobil {
}
}
}
}
String
fileName7
=
"favoriten.csv"
;
String
fileName7
=
"favoriten.csv"
;
CSVFileHelper
.
saveCSVFile
(
context
,
fileName7
,
csvBestellungen
);
CSVFileHelper
.
saveCSVFile
(
context
,
fileName7
,
csvFavoriten
);
//Customer-ID, Item-ID, quantity
String
csvShoppingCart
=
""
;
for
(
Customer
c:
MampfMobil
.
customers
){
for
(
BestellungsTeil
bT:
c
.
shoppingCart
){
csvShoppingCart
=
csvShoppingCart
+
c
.
id
+
","
+
bT
.
item
.
id
+
","
+
bT
.
quantity
+
"\n"
;
}
}
String
fileName8
=
"shoppingCart.csv"
;
CSVFileHelper
.
saveCSVFile
(
context
,
fileName8
,
csvShoppingCart
);
}
}
...
@@ -479,15 +490,17 @@ public class MampfMobil {
...
@@ -479,15 +490,17 @@ public class MampfMobil {
String
[]
lines
=
csvData7
.
split
(
"\n"
);
String
[]
lines
=
csvData7
.
split
(
"\n"
);
for
(
String
line
:
lines
)
{
for
(
String
line
:
lines
)
{
String
[]
data
=
line
.
split
(
","
);
String
[]
data
=
line
.
split
(
","
);
Log
.
d
(
"myTag"
,
"ADDED 1 fav"
);
if
(
data
.
length
>=
2
)
{
if
(
data
.
length
>=
2
)
{
int
cusId
=
Integer
.
parseInt
(
data
[
0
]);
int
cusId
=
Integer
.
parseInt
(
data
[
0
]);
int
shopItemId
=
Integer
.
parseInt
(
data
[
0
]);
int
shopItemId
=
Integer
.
parseInt
(
data
[
1
]);
Log
.
d
(
"myTag"
,
"ADDED 2 fav"
);
for
(
Customer
c
:
MampfMobil
.
customers
)
{
for
(
Customer
c
:
MampfMobil
.
customers
)
{
if
(
c
.
id
==
cusId
)
{
if
(
c
.
id
==
cusId
)
{
Log
.
d
(
"myTag"
,
"ADDED 3 fav"
);
for
(
Supplier
s
:
MampfMobil
.
suppliers
)
{
for
(
Supplier
s
:
MampfMobil
.
suppliers
)
{
for
(
ShopItem
sI
:
s
.
shopItems
)
{
for
(
ShopItem
sI
:
s
.
shopItems
)
{
Log
.
d
(
"myTag"
,
sI
.
id
+
""
+
shopItemId
);
if
(
sI
.
id
==
shopItemId
)
{
if
(
sI
.
id
==
shopItemId
)
{
c
.
addToFavourits
(
sI
);
c
.
addToFavourits
(
sI
);
}
}
...
@@ -498,5 +511,34 @@ public class MampfMobil {
...
@@ -498,5 +511,34 @@ public class MampfMobil {
}
}
}
}
}
}
String
fileName8
=
"shoppingCart.csv"
;
String
csvData8
=
CSVFileHelper
.
loadCSVFile
(
context
,
fileName8
);
if
(
csvData8
!=
null
)
{
String
[]
lines
=
csvData8
.
split
(
"\n"
);
for
(
String
line
:
lines
)
{
String
[]
data
=
line
.
split
(
","
);
if
(
data
.
length
>=
3
)
{
int
cusId
=
Integer
.
parseInt
(
data
[
0
]);
int
itemId
=
Integer
.
parseInt
(
data
[
1
]);
int
amount
=
Integer
.
parseInt
(
data
[
2
]);
for
(
Customer
c
:
MampfMobil
.
customers
)
{
if
(
c
.
id
==
cusId
)
{
for
(
Supplier
s
:
MampfMobil
.
suppliers
)
{
for
(
ShopItem
sI
:
s
.
shopItems
)
{
if
(
sI
.
item
.
id
==
itemId
)
{
c
.
addToShoppingCart
(
new
BestellungsTeil
(
sI
.
item
,
amount
));
}
}
}
}
}
}
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment