Commit e73c95e7 authored by Nastuzzi Samy's avatar Nastuzzi Samy

Variable price

Bug fix
Better management
More explicit views
parent 0d531246
......@@ -311,7 +311,7 @@ public class EditActivity extends ArticleGroupActivity {
StringBuilder builder = new StringBuilder(dest);
builder.replace(dstart, dend, source
.subSequence(start, end).toString());
if (!builder.toString().matches("(([1-9]{1})([0-9]{0,"+(maxDigitsBeforeDecimalPoint-1)+"})?)?(\\.[0-9]{0,"+maxDigitsAfterDecimalPoint+"})?")) {
if (!builder.toString().matches("((([1-9]{1})([0-9]{0,"+(maxDigitsBeforeDecimalPoint-1)+"})?)|0)?(\\.[0-9]{0,"+maxDigitsAfterDecimalPoint+"})?")) {
if (source.length() == 0)
return dest.subSequence(dstart, dend);
return "";
......@@ -444,7 +444,7 @@ public class EditActivity extends ArticleGroupActivity {
.setTitle(R.string.configuration)
.setView(popupView)
.setCancelable(false)
.setPositiveButton(R.string.reload, new DialogInterface.OnClickListener() {
.setPositiveButton(R.string.register, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int id) {
if (!nameInput.getText().toString().equals("") && (radioVariablePrice.isChecked() || !priceInput.getText().toString().equals(""))) {
dialog.startLoading(EditActivity.this, getString(R.string.article_edit), getString(R.string.article_editing));
......
......@@ -84,8 +84,14 @@ public abstract class ArticlesAdapter extends BaseAdapter {
this.clickViewList[position].setAlpha(0.0f);
}
else {
this.clickViewList[position].setText(this.nbrList[position] % 100 == 0 ? Integer.toString(this.nbrList[position] / 100) : Float.toString(this.nbrList[position] / 100.0f));
this.clickViewList[position].setAlpha(1.0f);
if (this.articleList.get(position).get("variable_price").booleanValue()) {
this.clickViewList[position].setText(this.nbrList[position] % 100 == 0 ? Integer.toString(this.nbrList[position] / 100) : Float.toString(this.nbrList[position] / 100.0f) + "€");
this.clickViewList[position].setBackgroundColor(Color.argb(255, 150, 200, 150));
}
else
this.clickViewList[position].setText(this.nbrList[position] % 100 == 0 ? Integer.toString(this.nbrList[position] / 100) : Float.toString(this.nbrList[position] / 100.0f));
}
}
......@@ -97,7 +103,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.price_variable);
text = articleList.get(position).get("name").textValue() + ": " + (getNbr(position) == 0 ? activity.getString(R.string.price_variable) : Float.toString(getNbr(position) / 100.0f) + '$');
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
......
......@@ -48,8 +48,12 @@ public class ListAdapater extends ArticlesAdapter {
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) + "€");
if (article.get("variable_price").booleanValue()) {
if (articleList.get(position).has("quantity"))
priceText.setText(String.format("%.2f", articleList.get(position).get("price").intValue() * articleList.get(position).get("quantity").intValue() / 100.00f) + "€");
else
priceText.setText(R.string.price_variable);
}
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) + "€");
}
......
......@@ -89,7 +89,7 @@ public class SellFragment extends ArticleGroupFragment {
StringBuilder builder = new StringBuilder(dest);
builder.replace(dstart, dend, source
.subSequence(start, end).toString());
if (!builder.toString().matches("(([1-9]{1})([0-9]{0,"+(maxDigitsBeforeDecimalPoint-1)+"})?)?(\\.[0-9]{0,"+maxDigitsAfterDecimalPoint+"})?")) {
if (!builder.toString().matches("((([1-9]{1})([0-9]{0,"+(maxDigitsBeforeDecimalPoint-1)+"})?)|0)?(\\.[0-9]{0,"+maxDigitsAfterDecimalPoint+"})?")) {
if (source.length() == 0)
return dest.subSequence(dstart, dend);
return "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment