Revision: 8108
Author: jlaba...@google.com
Date: Wed May 12 07:49:05 2010
Log: Updating Mobile expenses app now that prices are stored in dollars
instead of cents.
Review at http://gwt-code-reviews.appspot.com/514801
Review by: j...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=8108
Modified:
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/ExpensesMobile.java
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/MobileExpenseDetails.java
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/MobileExpenseEntry.java
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/MobileExpenseList.java
=======================================
---
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/ExpensesMobile.java
Mon May 10 10:53:16 2010
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/ExpensesMobile.java
Wed May 12 07:49:05 2010
@@ -28,10 +28,13 @@
/**
* TODO(jgw): Put this some place more sensible.
+ *
+ * @param amount the amount in dollars
*/
- public static String formatCurrency(int price) {
+ public static String formatCurrency(double amount) {
StringBuilder sb = new StringBuilder();
+ int price = (int) (amount * 100);
boolean negative = price < 0;
if (negative) {
price = -price;
=======================================
---
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/MobileExpenseDetails.java
Tue May 11 10:56:00 2010
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/MobileExpenseDetails.java
Wed May 12 07:49:05 2010
@@ -119,6 +119,6 @@
nameText.setInnerText(expense.getDescription());
dateText.setInnerText(formatter.format(expense.getCreated()));
categoryText.setInnerText(expense.getCategory());
-
priceText.setInnerText(ExpensesMobile.formatCurrency(expense.getAmount().intValue()));
+
priceText.setInnerText(ExpensesMobile.formatCurrency(expense.getAmount()));
}
}
=======================================
---
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/MobileExpenseEntry.java
Tue May 11 10:56:00 2010
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/MobileExpenseEntry.java
Wed May 12 07:49:05 2010
@@ -105,7 +105,7 @@
// TODO(jgw): validate amount (in dollars -- database is in pennies)
String amountText = priceText.getText();
double amount = Double.parseDouble(amountText);
- deltas.set(ExpenseRecord.amount, expense, amount * 100);
+ deltas.set(ExpenseRecord.amount, expense, amount);
// TODO(jgw): Use non-deprecated date methods for this.
Date date = new Date(
@@ -145,7 +145,7 @@
private void displayExpense() {
nameText.setText(expense.getDescription());
categoryText.setText(expense.getCategory());
-
priceText.setText(ExpensesMobile.formatCurrency(expense.getAmount().intValue()));
+ priceText.setText(ExpensesMobile.formatCurrency(expense.getAmount()));
// TODO(jgw): Use non-deprecated date methods for this.
Date d = expense.getCreated();
=======================================
---
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/MobileExpenseList.java
Tue May 11 07:01:15 2010
+++
/branches/2.1/bikeshed/src/com/google/gwt/sample/expenses/gwt/client/MobileExpenseList.java
Wed May 12 07:49:05 2010
@@ -44,6 +44,7 @@
*/
public interface Listener {
void onExpenseSelected(ExpenseRecord expense);
+
void onCreateExpense(String reportId);
}
@@ -65,8 +66,8 @@
@Override
public void render(ExpenseRecord value, Object viewData,
StringBuilder sb) {
- sb.append("<div onclick='' class='item'>" +
value.getDescription() + " ($" +
- ExpensesMobile.formatCurrency(value.getAmount().intValue())
+ sb.append("<div onclick='' class='item'>" +
value.getDescription()
+ + " ($" + ExpensesMobile.formatCurrency(value.getAmount())
+ ")</div>");
}
});
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors