Skip to content
GitLab
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
973fb138
Commit
973fb138
authored
Dec 07, 2017
by
Nastuzzi Samy
Browse files
Merge branch 'feature/editArticles' into develop
parents
8543a8d1
88ed4c3d
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/fr/utc/simde/jessy/ArticleGroupActivity.java
View file @
973fb138
...
...
@@ -34,8 +34,8 @@ import fr.utc.simde.jessy.tools.HTTPRequest;
public
abstract
class
ArticleGroupActivity
extends
BaseActivity
{
private
static
final
String
LOG_TAG
=
"_ArticleGroupActivity"
;
protected
ImageButton
paramButton
;
protected
ImageButton
optionButton
;
protected
ImageButton
deleteButton
;
protected
TabHost
tabHost
;
protected
List
<
ArticleGroupFragment
>
groupFragmentList
;
...
...
@@ -46,8 +46,8 @@ public abstract class ArticleGroupActivity extends BaseActivity {
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_article_group
);
this
.
param
Button
=
findViewById
(
R
.
id
.
image_param
);
this
.
option
Button
=
findViewById
(
R
.
id
.
image_delete
);
this
.
option
Button
=
findViewById
(
R
.
id
.
image_param
);
this
.
delete
Button
=
findViewById
(
R
.
id
.
image_delete
);
this
.
tabHost
=
findViewById
(
R
.
id
.
tab_categories
);
this
.
tabHost
.
setup
();
...
...
@@ -86,118 +86,12 @@ public abstract class ArticleGroupActivity extends BaseActivity {
});
}
this
.
paramButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
if
(
config
.
getFoundationId
()
==
-
1
)
{
final
View
popupView
=
LayoutInflater
.
from
(
ArticleGroupActivity
.
this
).
inflate
(
R
.
layout
.
dialog_config
,
null
,
false
);
final
RadioButton
radioKeyboard
=
popupView
.
findViewById
(
R
.
id
.
radio_keyboard
);
final
RadioButton
radioCategory
=
popupView
.
findViewById
(
R
.
id
.
radio_category
);
final
RadioButton
radioGrid
=
popupView
.
findViewById
(
R
.
id
.
radio_grid
);
final
RadioButton
radioList
=
popupView
.
findViewById
(
R
.
id
.
radio_list
);
final
Switch
switchCotisant
=
popupView
.
findViewById
(
R
.
id
.
swtich_cotisant
);
final
Switch
swtich18
=
popupView
.
findViewById
(
R
.
id
.
swtich_18
);
final
Button
configButton
=
popupView
.
findViewById
(
R
.
id
.
button_config
);
if
(
config
.
getInCategory
())
radioCategory
.
setChecked
(
true
);
else
radioKeyboard
.
setChecked
(
true
);
if
(
config
.
getInGrid
())
radioGrid
.
setChecked
(
true
);
else
radioList
.
setChecked
(
true
);
switchCotisant
.
setChecked
(
config
.
getPrintCotisant
());
swtich18
.
setChecked
(
config
.
getPrint18
());
configButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
final
View
view
)
{
hasRights
(
getString
(
R
.
string
.
configurate_by_default
),
new
String
[]{
"STAFF"
,
"GESAPPLICATIONS"
},
new
Runnable
()
{
@Override
public
void
run
()
{
configDialog
();
}
});
}
});
final
AlertDialog
.
Builder
alertDialogBuilder
=
new
AlertDialog
.
Builder
(
ArticleGroupActivity
.
this
);
alertDialogBuilder
.
setTitle
(
R
.
string
.
configuration
)
.
setView
(
popupView
)
.
setCancelable
(
false
)
.
setPositiveButton
(
R
.
string
.
reload
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialogInterface
,
int
id
)
{
config
.
setInCategory
(
radioCategory
.
isChecked
());
config
.
setInGrid
(
radioGrid
.
isChecked
());
config
.
setPrintCotisant
(
switchCotisant
.
isChecked
());
config
.
setPrint18
(
swtich18
.
isChecked
());
startSellActivity
(
ArticleGroupActivity
.
this
);
}
})
.
setNegativeButton
(
R
.
string
.
cancel
,
null
);
dialog
.
createDialog
(
alertDialogBuilder
);
}
else
{
final
View
popupView
=
LayoutInflater
.
from
(
ArticleGroupActivity
.
this
).
inflate
(
R
.
layout
.
dialog_config_restore
,
null
,
false
);
final
Switch
switchCotisant
=
popupView
.
findViewById
(
R
.
id
.
swtich_cotisant
);
final
Switch
swtich18
=
popupView
.
findViewById
(
R
.
id
.
swtich_18
);
final
Button
configButton
=
popupView
.
findViewById
(
R
.
id
.
button_config
);
switchCotisant
.
setChecked
(
config
.
getPrintCotisant
());
swtich18
.
setChecked
(
config
.
getPrint18
());
configButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
hasRights
(
getString
(
R
.
string
.
configurate_by_default
),
new
String
[]{
"STAFF"
,
"GESAPPLICATIONS"
},
new
Runnable
()
{
@Override
public
void
run
()
{
config
.
setFoundation
(-
1
,
""
);
config
.
setLocation
(-
1
,
""
);
config
.
setCanCancel
(
true
);
startMainActivity
(
ArticleGroupActivity
.
this
);
}
});
}
});
final
AlertDialog
.
Builder
alertDialogBuilder
=
new
AlertDialog
.
Builder
(
ArticleGroupActivity
.
this
);
alertDialogBuilder
.
setTitle
(
R
.
string
.
configuration
)
.
setView
(
popupView
)
.
setCancelable
(
false
)
.
setPositiveButton
(
R
.
string
.
reload
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialogInterface
,
int
id
)
{
config
.
setPrintCotisant
(
switchCotisant
.
isChecked
());
config
.
setPrint18
(
swtich18
.
isChecked
());
startSellActivity
(
ArticleGroupActivity
.
this
);
}
})
.
setNegativeButton
(
R
.
string
.
cancel
,
null
);
dialog
.
createDialog
(
alertDialogBuilder
);
}
}
});
setOptionButton
();
setDeleteButton
();
}
protected
abstract
void
setOptionButton
();
protected
abstract
void
setDeleteButton
();
protected
void
configDialog
()
{
dialog
.
startLoading
(
ArticleGroupActivity
.
this
,
getResources
().
getString
(
R
.
string
.
information_collection
),
getString
(
config
.
getInCategory
()
?
R
.
string
.
category_list_collecting
:
R
.
string
.
keyboard_list_collecting
));
...
...
@@ -323,13 +217,11 @@ public abstract class ArticleGroupActivity extends BaseActivity {
ArrayNode
articlesForThisCategory
=
articlesPerCategory
.
get
(
category
.
get
(
"id"
).
intValue
());
if
(
config
.
getFoundationId
()
!=
-
1
)
if
(!
authorizedList
.
contains
(
category
.
get
(
"id"
).
intValue
()))
continue
;
else
if
(
articlesForThisCategory
.
size
()
==
0
)
continue
;
if
(
articlesForThisCategory
==
null
)
continue
;
articlesForThisCategory
=
new
ObjectMapper
().
createArrayNode
()
;
createNewGroup
(
category
.
get
(
"name"
).
textValue
(),
articlesForThisCategory
);
createNewGroup
(
category
.
get
(
"name"
).
textValue
(),
category
.
get
(
"id"
).
intValue
(),
articlesForThisCategory
);
}
}
...
...
@@ -373,13 +265,10 @@ public abstract class ArticleGroupActivity extends BaseActivity {
articlesForThisKeyboard
.
add
(
new
ObjectMapper
().
createObjectNode
());
}
if
(
articlesForThisKeyboard
.
size
()
==
0
)
continue
;
createNewGroup
(
keyboard
.
get
(
"name"
).
textValue
(),
articlesForThisKeyboard
,
keyboard
.
get
(
"data"
).
get
(
"nbColumns"
).
isInt
()
?
keyboard
.
get
(
"data"
).
get
(
"nbColumns"
).
intValue
()
:
Integer
.
valueOf
(
keyboard
.
get
(
"data"
).
get
(
"nbColumns"
).
textValue
()));
createNewGroup
(
keyboard
.
get
(
"name"
).
textValue
(),
keyboard
.
get
(
"id"
).
intValue
(),
articlesForThisKeyboard
,
keyboard
.
get
(
"data"
).
get
(
"nbColumns"
).
isInt
()
?
keyboard
.
get
(
"data"
).
get
(
"nbColumns"
).
intValue
()
:
Integer
.
valueOf
(
keyboard
.
get
(
"data"
).
get
(
"nbColumns"
).
textValue
()));
}
}
protected
abstract
void
createNewGroup
(
final
String
name
,
final
ArrayNode
articleList
)
throws
Exception
;
protected
abstract
void
createNewGroup
(
final
String
name
,
final
ArrayNode
articleList
,
int
gridColumns
)
throws
Exception
;
protected
abstract
void
createNewGroup
(
final
String
name
,
final
Integer
id
,
final
ArrayNode
articleList
)
throws
Exception
;
protected
abstract
void
createNewGroup
(
final
String
name
,
final
Integer
id
,
final
ArrayNode
articleList
,
int
gridColumns
)
throws
Exception
;
}
app/src/main/java/fr/utc/simde/jessy/EditActivity.java
View file @
973fb138
This diff is collapsed.
Click to expand it.
app/src/main/java/fr/utc/simde/jessy/SellActivity.java
View file @
973fb138
...
...
@@ -15,7 +15,9 @@ import android.widget.TextView;
import
android.widget.Toast
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -112,7 +114,7 @@ public class SellActivity extends ArticleGroupActivity {
dialog
.
stopLoading
();
Toast
.
makeText
(
SellActivity
.
this
,
getString
(
R
.
string
.
ticket_realized
),
Toast
.
LENGTH_LONG
).
show
();
setBackgroundColor
(
getResources
().
getColor
(
R
.
color
.
success
));
((
Vibrator
)
getSystemService
(
ArticleGroup
Activity
.
VIBRATOR_SERVICE
)).
vibrate
(
250
);
((
Vibrator
)
getSystemService
(
Sell
Activity
.
VIBRATOR_SERVICE
)).
vibrate
(
250
);
}
});
}
catch
(
final
Exception
e
)
{
...
...
@@ -128,7 +130,7 @@ public class SellActivity extends ArticleGroupActivity {
dialog
.
stopLoading
();
dialog
.
errorDialog
(
SellActivity
.
this
,
getString
(
R
.
string
.
paiement
),
response
.
get
(
"error"
).
get
(
"message"
).
textValue
());
setBackgroundColor
(
getResources
().
getColor
(
R
.
color
.
error
));
((
Vibrator
)
getSystemService
(
ArticleGroup
Activity
.
VIBRATOR_SERVICE
)).
vibrate
(
500
);
((
Vibrator
)
getSystemService
(
Sell
Activity
.
VIBRATOR_SERVICE
)).
vibrate
(
500
);
}
});
}
...
...
@@ -141,7 +143,7 @@ public class SellActivity extends ArticleGroupActivity {
dialog
.
stopLoading
();
dialog
.
errorDialog
(
SellActivity
.
this
,
getString
(
R
.
string
.
paiement
),
e
.
getMessage
());
setBackgroundColor
(
getResources
().
getColor
(
R
.
color
.
error
));
((
Vibrator
)
getSystemService
(
ArticleGroup
Activity
.
VIBRATOR_SERVICE
)).
vibrate
(
500
);
((
Vibrator
)
getSystemService
(
Sell
Activity
.
VIBRATOR_SERVICE
)).
vibrate
(
500
);
}
});
}
...
...
@@ -155,14 +157,125 @@ public class SellActivity extends ArticleGroupActivity {
this
.
optionButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
clearPanier
();
if
(
config
.
getFoundationId
()
==
-
1
)
{
final
View
popupView
=
LayoutInflater
.
from
(
SellActivity
.
this
).
inflate
(
R
.
layout
.
dialog_config
,
null
,
false
);
final
RadioButton
radioKeyboard
=
popupView
.
findViewById
(
R
.
id
.
radio_keyboard
);
final
RadioButton
radioCategory
=
popupView
.
findViewById
(
R
.
id
.
radio_category
);
final
RadioButton
radioGrid
=
popupView
.
findViewById
(
R
.
id
.
radio_grid
);
final
RadioButton
radioList
=
popupView
.
findViewById
(
R
.
id
.
radio_list
);
final
Switch
switchCotisant
=
popupView
.
findViewById
(
R
.
id
.
swtich_cotisant
);
final
Switch
swtich18
=
popupView
.
findViewById
(
R
.
id
.
swtich_18
);
final
Button
configButton
=
popupView
.
findViewById
(
R
.
id
.
button_config
);
if
(
config
.
getInCategory
())
radioCategory
.
setChecked
(
true
);
else
radioKeyboard
.
setChecked
(
true
);
if
(
config
.
getInGrid
())
radioGrid
.
setChecked
(
true
);
else
radioList
.
setChecked
(
true
);
switchCotisant
.
setChecked
(
config
.
getPrintCotisant
());
swtich18
.
setChecked
(
config
.
getPrint18
());
configButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
final
View
view
)
{
hasRights
(
getString
(
R
.
string
.
configurate_by_default
),
new
String
[]{
"STAFF"
,
"GESAPPLICATIONS"
},
new
Runnable
()
{
@Override
public
void
run
()
{
configDialog
();
}
});
}
});
final
AlertDialog
.
Builder
alertDialogBuilder
=
new
AlertDialog
.
Builder
(
SellActivity
.
this
);
alertDialogBuilder
.
setTitle
(
R
.
string
.
configuration
)
.
setView
(
popupView
)
.
setCancelable
(
false
)
.
setPositiveButton
(
R
.
string
.
reload
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialogInterface
,
int
id
)
{
config
.
setInCategory
(
radioCategory
.
isChecked
());
config
.
setInGrid
(
radioGrid
.
isChecked
());
config
.
setPrintCotisant
(
switchCotisant
.
isChecked
());
config
.
setPrint18
(
swtich18
.
isChecked
());
startSellActivity
(
SellActivity
.
this
);
}
})
.
setNegativeButton
(
R
.
string
.
cancel
,
null
);
dialog
.
createDialog
(
alertDialogBuilder
);
}
else
{
final
View
popupView
=
LayoutInflater
.
from
(
SellActivity
.
this
).
inflate
(
R
.
layout
.
dialog_config_restore
,
null
,
false
);
final
Switch
switchCotisant
=
popupView
.
findViewById
(
R
.
id
.
swtich_cotisant
);
final
Switch
swtich18
=
popupView
.
findViewById
(
R
.
id
.
swtich_18
);
final
Button
configButton
=
popupView
.
findViewById
(
R
.
id
.
button_config
);
switchCotisant
.
setChecked
(
config
.
getPrintCotisant
());
swtich18
.
setChecked
(
config
.
getPrint18
());
configButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
hasRights
(
getString
(
R
.
string
.
configurate_by_default
),
new
String
[]{
"STAFF"
,
"GESAPPLICATIONS"
},
new
Runnable
()
{
@Override
public
void
run
()
{
config
.
setFoundation
(-
1
,
""
);
config
.
setLocation
(-
1
,
""
);
config
.
setCanCancel
(
true
);
startMainActivity
(
SellActivity
.
this
);
}
});
}
});
final
AlertDialog
.
Builder
alertDialogBuilder
=
new
AlertDialog
.
Builder
(
SellActivity
.
this
);
alertDialogBuilder
.
setTitle
(
R
.
string
.
configuration
)
.
setView
(
popupView
)
.
setCancelable
(
false
)
.
setPositiveButton
(
R
.
string
.
reload
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialogInterface
,
int
id
)
{
config
.
setPrintCotisant
(
switchCotisant
.
isChecked
());
config
.
setPrint18
(
swtich18
.
isChecked
());
startSellActivity
(
SellActivity
.
this
);
}
})
.
setNegativeButton
(
R
.
string
.
cancel
,
null
);
dialog
.
createDialog
(
alertDialogBuilder
);
}
}
});
}
@Override
protected
void
createNewGroup
(
final
String
name
,
final
ArrayNode
articleList
)
throws
Exception
{
createNewGroup
(
name
,
articleList
,
3
);
}
protected
void
createNewGroup
(
final
String
name
,
final
ArrayNode
articleList
,
int
gridColumns
)
throws
Exception
{
protected
void
setDeleteButton
()
{
this
.
deleteButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
clearPanier
();
}
});
}
@Override
protected
void
createNewGroup
(
final
String
name
,
final
Integer
id
,
final
ArrayNode
articleList
)
throws
Exception
{
createNewGroup
(
name
,
id
,
articleList
,
3
);
}
protected
void
createNewGroup
(
final
String
name
,
final
Integer
id
,
final
ArrayNode
articleList
,
int
gridColumns
)
throws
Exception
{
ArticleGroupFragment
articleGroupFragment
=
new
SellFragment
(
SellActivity
.
this
,
this
.
dialog
,
articleList
,
this
.
panier
,
this
.
config
,
gridColumns
);
TabHost
.
TabSpec
newTabSpec
=
this
.
tabHost
.
newTabSpec
(
name
);
...
...
app/src/main/java/fr/utc/simde/jessy/adapters/ArticlesAdapter.java
View file @
973fb138
...
...
@@ -97,7 +97,7 @@ public abstract class ArticlesAdapter extends BaseAdapter {
String
text
;
if
(
articleList
.
get
(
position
).
get
(
"variable_price"
).
booleanValue
())
text
=
articleList
.
get
(
position
).
get
(
"name"
).
textValue
()
+
": "
+
activity
.
getString
(
R
.
string
.
variable
_price
);
text
=
articleList
.
get
(
position
).
get
(
"name"
).
textValue
()
+
": "
+
activity
.
getString
(
R
.
string
.
price_
variable
);
else
if
(
articleList
.
get
(
position
).
has
(
"quantity"
))
text
=
Integer
.
toString
(
articleList
.
get
(
position
).
get
(
"quantity"
).
intValue
())
+
"x "
+
articleList
.
get
(
position
).
get
(
"name"
).
textValue
()
+
": "
+
Integer
.
toString
(
articleList
.
get
(
position
).
get
(
"quantity"
).
intValue
())
+
"x "
+
String
.
format
(
"%.2f"
,
new
Float
(
articleList
.
get
(
position
).
get
(
"price"
).
intValue
())
/
100.00f
)
+
"€"
;
else
...
...
app/src/main/java/fr/utc/simde/jessy/adapters/GridAdapter.java
View file @
973fb138
...
...
@@ -57,7 +57,13 @@ public class GridAdapter extends ArticlesAdapter {
imageCotisant
.
setLayoutParams
(
imageParms
);
image18
.
setLayoutParams
(
imageParms
);
setInfos
(
article
,
imageCotisant
,
image18
);
if
(
article
.
get
(
"id"
).
intValue
()
==
-
1
)
{
imageCotisant
.
setVisibility
(
View
.
GONE
);
image18
.
setVisibility
(
View
.
GONE
);
}
else
setInfos
(
article
,
imageCotisant
,
image18
);
setImage
(
imageView
,
article
.
get
(
"image_url"
).
textValue
(),
position
);
setClickView
(
position
);
}
...
...
app/src/main/java/fr/utc/simde/jessy/adapters/ListAdapater.java
View file @
973fb138
...
...
@@ -45,10 +45,14 @@ public class ListAdapater extends ArticlesAdapter {
TextView
priceText
=
this
.
viewList
[
position
].
findViewById
(
R
.
id
.
text_price
);
if
(
article
.
get
(
"variable_price"
).
booleanValue
())
priceText
.
setText
(
"PV: "
+
String
.
format
(
"%.2f"
,
new
Float
(
articleList
.
get
(
position
).
get
(
"price"
).
intValue
()
*
articleList
.
get
(
position
).
get
(
"quantity"
).
intValue
())
/
100.00f
)
+
"€"
);
else
priceText
.
setText
((
article
.
has
(
"quantity"
)
?
Integer
.
toString
(
article
.
get
(
"quantity"
).
intValue
())
+
"x "
:
""
)
+
String
.
format
(
"%.2f"
,
new
Float
(
articleList
.
get
(
position
).
get
(
"price"
).
intValue
())
/
100.00f
)
+
"€"
);
if
(
article
.
get
(
"id"
).
intValue
()
==
-
1
)
priceText
.
setVisibility
(
View
.
GONE
);
else
{
if
(
article
.
get
(
"variable_price"
).
booleanValue
())
priceText
.
setText
(
"PV: "
+
String
.
format
(
"%.2f"
,
new
Float
(
articleList
.
get
(
position
).
get
(
"price"
).
intValue
())
/
100.00f
)
+
"€"
);
else
priceText
.
setText
((
article
.
has
(
"quantity"
)
?
Integer
.
toString
(
article
.
get
(
"quantity"
).
intValue
())
+
"x "
:
""
)
+
String
.
format
(
"%.2f"
,
new
Float
(
articleList
.
get
(
position
).
get
(
"price"
).
intValue
())
/
100.00f
)
+
"€"
);
}
ImageView
imageCotisant
=
this
.
viewList
[
position
].
findViewById
(
R
.
id
.
image_cotisant
);
ImageView
image18
=
this
.
viewList
[
position
].
findViewById
(
R
.
id
.
image_18
);
...
...
@@ -60,6 +64,10 @@ public class ListAdapater extends ArticlesAdapter {
imageCotisant
.
setVisibility
(
View
.
GONE
);
image18
.
setVisibility
(
View
.
GONE
);
}
else
if
(
article
.
get
(
"id"
).
intValue
()
==
-
1
)
{
imageCotisant
.
setVisibility
(
View
.
GONE
);
image18
.
setVisibility
(
View
.
GONE
);
}
else
setInfos
(
article
,
imageCotisant
,
image18
);
...
...
app/src/main/java/fr/utc/simde/jessy/fragments/EditFragment.java
View file @
973fb138
...
...
@@ -3,19 +3,25 @@ package fr.utc.simde.jessy.fragments;
import
android.app.Activity
;
import
android.content.DialogInterface
;
import
android.support.v7.app.AlertDialog
;
import
android.text.InputFilter
;
import
android.text.Spanned
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.EditText
;
import
android.widget.GridView
;
import
android.widget.ListView
;
import
android.widget.RadioButton
;
import
android.widget.Switch
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
fr.utc.simde.jessy.BaseActivity
;
import
fr.utc.simde.jessy.EditActivity
;
import
fr.utc.simde.jessy.R
;
import
fr.utc.simde.jessy.SellActivity
;
import
fr.utc.simde.jessy.tools.Config
;
import
fr.utc.simde.jessy.tools.Dialog
;
...
...
@@ -44,34 +50,7 @@ public class EditFragment extends ArticleGroupFragment {
AdapterView
.
OnItemClickListener
onItemClickListener
=
new
AdapterView
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
AdapterView
parent
,
View
view
,
int
position
,
long
id
)
{
final
JsonNode
article
=
articlesAdapter
.
getArticle
(
position
);
final
View
popupView
=
LayoutInflater
.
from
(
activity
).
inflate
(
R
.
layout
.
dialog_edit_article
,
null
,
false
);
final
EditText
textName
=
popupView
.
findViewById
(
R
.
id
.
text_name
);
final
EditText
textPrice
=
popupView
.
findViewById
(
R
.
id
.
text_price
);
final
Switch
switchCotisant
=
popupView
.
findViewById
(
R
.
id
.
swtich_cotisant
);
final
Switch
swtich18
=
popupView
.
findViewById
(
R
.
id
.
swtich_18
);
textName
.
setText
(
article
.
get
(
"name"
).
textValue
());
textPrice
.
setText
(
Float
.
toString
(
article
.
get
(
"price"
).
intValue
()
/
100.0f
));
switchCotisant
.
setChecked
(
article
.
get
(
"cotisant"
).
booleanValue
());
swtich18
.
setChecked
(
article
.
get
(
"alcool"
).
booleanValue
());
final
AlertDialog
.
Builder
alertDialogBuilder
=
new
AlertDialog
.
Builder
(
activity
);
alertDialogBuilder
.
setTitle
(
R
.
string
.
configuration
)
.
setView
(
popupView
)
.
setCancelable
(
false
)
.
setPositiveButton
(
R
.
string
.
reload
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialogInterface
,
int
id
)
{
config
.
setPrintCotisant
(
switchCotisant
.
isChecked
());
config
.
setPrint18
(
swtich18
.
isChecked
());
((
BaseActivity
)
activity
).
startSellActivity
(
activity
);
}
})
.
setNegativeButton
(
R
.
string
.
cancel
,
null
);
dialog
.
createDialog
(
alertDialogBuilder
);
((
EditActivity
)
activity
).
setArticle
(
articlesAdapter
,
position
);
}
};
...
...
app/src/main/java/fr/utc/simde/jessy/fragments/SellFragment.java
View file @
973fb138
...
...
@@ -105,7 +105,7 @@ public class SellFragment extends ArticleGroupFragment {
final
AlertDialog
.
Builder
alertDialogBuilder
=
new
AlertDialog
.
Builder
(
activity
);
alertDialogBuilder
.
setTitle
(
R
.
string
.
variable
_price
)
.
setTitle
(
R
.
string
.
price_
variable
)
.
setView
(
priceView
)
.
setCancelable
(
false
)
.
setPositiveButton
(
R
.
string
.
add
,
new
DialogInterface
.
OnClickListener
()
{
...
...
app/src/main/java/fr/utc/simde/jessy/responses/ArticleResponse.java
View file @
973fb138
...
...
@@ -16,6 +16,7 @@ public class ArticleResponse {
protected
int
fundation_id
;
protected
int
categorie_id
;
protected
int
price
;
protected
boolean
variable_price
;
protected
boolean
cotisant
;
protected
boolean
alcool
;
protected
boolean
active
;
...
...
@@ -25,6 +26,7 @@ public class ArticleResponse {
public
int
getFoundationId
()
{
return
this
.
fundation_id
;
}
public
int
getCategoryId
()
{
return
this
.
categorie_id
;
}
public
int
getPrice
()
{
return
this
.
price
;
}
public
boolean
getIsVariablePrice
()
{
return
this
.
variable_price
;
}
public
boolean
getIsContributerOnly
()
{
return
this
.
cotisant
;
}
public
boolean
getIsAdultOnly
()
{
return
this
.
alcool
;
}
public
boolean
getIsActive
()
{
return
this
.
active
;
}
...
...
app/src/main/java/fr/utc/simde/jessy/tools/Dialog.java
View file @
973fb138
...
...
@@ -74,10 +74,26 @@ public class Dialog {
}
}
public
void
choiceDialog
(
final
Activity
activity
,
final
String
title
,
final
String
message
,
final
DialogInterface
.
OnClickListener
onClickListenerYes
,
final
DialogInterface
.
OnClickListener
onClickListenerNo
)
{
this
.
activity
=
activity
;
dismiss
();
this
.
alertDialogBuilder
=
new
AlertDialog
.
Builder
(
activity
);
this
.
alertDialogBuilder
.
setTitle
(
title
)
.
setMessage
(
message
)
.
setCancelable
(
false
)
.
setPositiveButton
(
R
.
string
.
yes
,
onClickListenerYes
)
.
setNegativeButton
(
R
.
string
.
no
,
onClickListenerNo
);
createDialog
();
}
public
void
infoDialog
(
final
Activity
activity
,
final
String
title
,
final
String
message
)
{
errorDialog
(
activity
,
title
,
message
,
null
);
}
public
void
infoDialog
(
final
Activity
activity
,
final
String
title
,
final
String
message
,
final
DialogInterface
.
OnClickListener
onClickListener
)
{
this
.
activity
=
activity
;
dismiss
();
this
.
alertDialogBuilder
=
new
AlertDialog
.
Builder
(
activity
);
this
.
alertDialogBuilder
.
setTitle
(
title
)
...
...
app/src/main/java/fr/utc/simde/jessy/tools/HTTPRequest.java
View file @
973fb138
...
...
@@ -110,7 +110,7 @@ public class HTTPRequest {
this
.
request
.
setDoOutput
(
true
);
DataOutputStream
os
=
new
DataOutputStream
(
this
.
request
.
getOutputStream
());
os
.
write
Bytes
(
post
);
os
.
write
(
post
.
getBytes
(
"UTF-8"
)
);
os
.
flush
();
os
.
close
();
...
...
@@ -270,7 +270,7 @@ public class HTTPRequest {
return
data
.
equals
(
""
)
?
""
:
"?"
+
data
.
substring
(
0
,
data
.
length
()
-
1
);
}
protected
JsonNode
map2JsonNode
(
Map
<
String
,
Object
>
args
)
{
protected
JsonNode
map2JsonNode
(
Map
<
String
,
Object
>
args
)
throws
UnsupportedEncodingException
{
ObjectNode
data
=
new
ObjectMapper
().
createObjectNode
();
for
(
String
arg
:
args
.
keySet
())
{
...
...
@@ -293,7 +293,7 @@ public class HTTPRequest {
return
data
;
}
protected
String
post2String
(
Map
<
String
,
Object
>
args
)
{
protected
String
post2String
(
Map
<
String
,
Object
>
args
)
throws
UnsupportedEncodingException
{
return
map2JsonNode
(
args
).
toString
();
}
...
...
app/src/main/java/fr/utc/simde/jessy/tools/NemopaySession.java
View file @
973fb138
...
...
@@ -105,6 +105,101 @@ public class NemopaySession {
public
int
getLocationId
()
{
return
locationId
;
}
public
String
getFoundationName
()
{
return
foundationName
;
}
public
int
delArticle
(
final
int
id
)
throws
Exception
{
if
(!
isConnected
())
throw
new
Exception
(
this
.
notLogged
);
if
(
this
.
foundationId
==
-
1
)
throw
new
Exception
(
"No foundation set"
);
return
request
(
"GESARTICLE"
,
"deleteProduct"
,
new
HashMap
<
String
,
Object
>()
{{
put
(
"obj_id"
,
id
);
put
(
"fun_id"
,
foundationId
);
}},
new
String
[]{
"POSS3"
,