Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hds
flexin
android-app
Commits
d8ebd545
Commit
d8ebd545
authored
Nov 09, 2017
by
Nastuzzi Samy
Browse files
Bug fix
Connection errors Duplicate articles Annulation update
parent
1ed54ce9
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/fr/utc/simde/payutc/BaseActivity.java
View file @
d8ebd545
...
...
@@ -61,11 +61,10 @@ public abstract class BaseActivity extends NFCActivity {
dialog
.
fatalDialog
(
activity
,
title
,
message
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
unregister
(
activity
);
startMainActivity
(
activity
);
}
});
disconnect
();
}
protected
void
hasRights
(
final
String
titre
,
final
String
[]
rightList
,
final
Runnable
runnable
)
{
...
...
app/src/main/java/fr/utc/simde/payutc/BuyerInfoActivity.java
View file @
d8ebd545
...
...
@@ -244,24 +244,26 @@ public class BuyerInfoActivity extends BaseActivity {
final
ArrayNode
articleList
=
new
ObjectMapper
().
createArrayNode
();
Boolean
hasRight
=
true
;
//
for
(
JsonNode
purchase
:
lastPurchaseList
)
{
int
articleId
=
purchase
.
get
(
"obj_id"
).
intValue
();
Boolean
isIn
=
false
;
for
(
JsonNode
article
:
articleFoundationList
)
{
if
(
article
.
get
(
"id"
).
intValue
()
==
articleId
)
{
((
ObjectNode
)
article
).
put
(
"info"
,
getString
(
R
.
string
.
realized
)
+
" "
+
purchase
.
get
(
"pur_date"
).
textValue
().
substring
(
purchase
.
get
(
"pur_date"
).
textValue
().
length
()
-
8
));
((
ObjectNode
)
article
).
put
(
"quantity"
,
Math
.
round
(
purchase
.
get
(
"pur_qte"
).
floatValue
()));
((
ObjectNode
)
article
).
put
(
"purchase_id"
,
purchase
.
get
(
"pur_id"
).
intValue
());
articleList
.
add
(
article
);
isIn
=
true
;
break
;
try
{
for
(
JsonNode
purchase
:
lastPurchaseList
)
{
int
articleId
=
purchase
.
get
(
"obj_id"
).
intValue
();
Boolean
isIn
=
false
;
for
(
JsonNode
article
:
articleFoundationList
)
{
if
(
article
.
get
(
"id"
).
intValue
()
==
articleId
)
{
ObjectNode
toAdd
=
(
ObjectNode
)
new
ObjectMapper
().
readTree
(
article
.
toString
());
toAdd
.
put
(
"info"
,
getString
(
R
.
string
.
realized
)
+
" "
+
purchase
.
get
(
"pur_date"
).
textValue
().
substring
(
purchase
.
get
(
"pur_date"
).
textValue
().
length
()
-
8
));
toAdd
.
put
(
"quantity"
,
Math
.
round
(
purchase
.
get
(
"pur_qte"
).
floatValue
()));
toAdd
.
put
(
"purchase_id"
,
purchase
.
get
(
"pur_id"
).
intValue
());
articleList
.
add
(
toAdd
);
isIn
=
true
;
break
;
}
}
}
if
(!
isIn
)
{
try
{
if
(!
isIn
)
{
articleList
.
add
(
new
ObjectMapper
().
readTree
(
"{"
+
"\"name\":\""
+
"N°: "
+
Integer
.
toString
(
purchase
.
get
(
"obj_id"
).
intValue
())
+
"\", "
+
"\"price\":"
+
Integer
.
toString
(
purchase
.
get
(
"pur_price"
).
intValue
())
+
", "
+
...
...
@@ -271,23 +273,23 @@ public class BuyerInfoActivity extends BaseActivity {
"\"image_url\":\"\"}"
));
}
catch
(
Exception
e
)
{
Log
.
e
(
LOG_TAG
,
"error: "
+
e
.
getMessage
());
}
}
catch
(
Exception
e
)
{
Log
.
e
(
LOG_TAG
,
"error: "
+
e
.
getMessage
());
runOnUiThread
(
new
Runnable
()
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
dialog
.
stopLoading
();
dialog
.
errorDialog
(
BuyerInfoActivity
.
this
,
getResources
().
getString
(
R
.
string
.
information_collection
),
getResources
().
getString
(
R
.
string
.
error_view
),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
run
()
{
dialog
.
stopLoading
();
dialog
.
errorDialog
(
BuyerInfoActivity
.
this
,
getResources
().
getString
(
R
.
string
.
information_collection
),
getResources
().
getString
(
R
.
string
.
error_view
),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
id
)
{
finish
();
}
});
public
void
onClick
(
DialogInterface
dialogInterface
,
int
id
)
{
finish
();
}
});
}
}
}
);
}
runOnUiThread
(
new
Runnable
()
{
...
...
app/src/main/java/fr/utc/simde/payutc/adapters/ListAdapater.java
View file @
d8ebd545
package
fr.utc.simde.payutc.adapters
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.graphics.Color
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -24,6 +26,7 @@ public class ListAdapater extends ArticlesAdapter {
super
(
activity
,
articleList
,
printCotisant
,
print18
);
}
@SuppressLint
(
"ResourceAsColor"
)
@Override
public
View
getView
(
int
position
,
View
view
,
ViewGroup
viewGroup
)
{
JsonNode
article
=
this
.
articleList
.
get
(
position
);
...
...
@@ -61,6 +64,9 @@ public class ListAdapater extends ArticlesAdapter {
nbrClicksList
[
position
]
=
article
.
get
(
"quantity"
).
intValue
();
}
if
(
this
.
nbrClicksList
[
position
]
<
0
)
priceText
.
setTextColor
(
Color
.
RED
);
setClickView
(
position
);
}
...
...
@@ -79,6 +85,9 @@ public class ListAdapater extends ArticlesAdapter {
}
else
{
this
.
clickViewList
[
position
].
setText
(
Integer
.
toString
(
this
.
nbrClicksList
[
position
]));
this
.
clickViewList
[
position
].
setAlpha
(
1.0f
);
if
(
this
.
nbrClicksList
[
position
]
<
0
)
this
.
clickViewList
[
position
].
setBackgroundColor
(
Color
.
RED
);
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment