Skip to content

Commit

Permalink
Moved name for new user button to strings.xml. Fixed exceptions in Ad…
Browse files Browse the repository at this point in the history
…dUserActivity.java.
  • Loading branch information
Donnerbart committed Oct 29, 2013
1 parent 1b2a9b9 commit 3a6409b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions meteroid/src/main/java/de/chaosdorf/meteroid/AddUserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void onClick(View view)
final CharSequence username = usernameText.getText();
final CharSequence email = emailText.getText();
final CharSequence balance = balanceText.getText();
if (username == null)
if (username == null || username.length() == 0)
{
Utility.displayToastMessage(activity, getResources().getString(R.string.add_user_empty_username));
return;
Expand All @@ -54,12 +54,21 @@ public void onClick(View view)
{
emailValue = email.toString();
}
if (balance == null)
if (balance == null || balance.length() == 0)
{
Utility.displayToastMessage(activity, getResources().getString(R.string.add_user_empty_balance));
return;
}
double balanceValue;
try
{
balanceValue = Double.parseDouble(balance.toString());
}
catch (NumberFormatException ignored)
{
Utility.displayToastMessage(activity, getResources().getString(R.string.add_user_empty_balance));
return;
}
final double balanceValue = Double.parseDouble(balance.toString());
final User user = new User(0,
username.toString(),
emailValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void processIOResult(final LongRunningIOTask task, final String json)
if (task == LongRunningIOTask.GET_USERS && json != null)
{
final List<User> itemList = UserController.parseAllUsersFromJSON(json);
itemList.add(new User(NEW_USER_ID, "Neuer Benutzer", "", 0, new Date(), new Date()));
itemList.add(new User(NEW_USER_ID, getResources().getString(R.string.pick_username_new_user), "", 0, new Date(), new Date()));
final UserAdapter userAdapter = new UserAdapter(itemList);

gridView.setAdapter(userAdapter);
Expand Down
1 change: 1 addition & 0 deletions meteroid/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<!-- Pick username -->
<string name="pick_username_label">Pick your username</string>
<string name="pick_username_new_user">New</string>
<string name="pick_username_error">Could not load user list. Please check network connection or
reset hostname to proceed.
</string>
Expand Down

0 comments on commit 3a6409b

Please sign in to comment.