Skip to content

Commit

Permalink
Fixes #66
Browse files Browse the repository at this point in the history
  • Loading branch information
dieechtenilente committed Nov 27, 2018
1 parent fc22ef8 commit d2e7d9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ private void updateDrinkList() {
ArrayList<Drink> depletedDrinks = currentUser.depletedDrinks;
double totalBac = 0;

// Converting from Alkomat 3000 v1.9 and older
if (depletedDrinks == null) {
depletedDrinks = new ArrayList<>();
}

if (!drinks.isEmpty()) {
/*
If you have 2 items in your list and remove the first one, index 1 is gone and the for each loop throws an
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/de/klaushackner/breathalyzer/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public User(String name, boolean isMale, int age, int weight, int height) {
this.weight = weight;
this.height = height;
this.created = System.currentTimeMillis();
this.drinks = new ArrayList<Drink>();
this.depletedDrinks = new ArrayList<Drink>();
this.drinks = new ArrayList<>();
this.depletedDrinks = new ArrayList<>();
}

public User(JSONObject user) {
Expand All @@ -54,7 +54,7 @@ public User(JSONObject user) {
this.created = user.getLong("created");

JSONArray drinksJSON = user.getJSONArray("drinks");
drinks = new ArrayList<Drink>();
drinks = new ArrayList<>();

for (int i = 0; i < drinksJSON.length(); i++) {
drinks.add(new Drink(drinksJSON.getJSONObject(i), this));
Expand All @@ -66,7 +66,7 @@ public User(JSONObject user) {
if (depletedDrinksJSON == null) {
depletedDrinksJSON = new JSONArray();
} else {
depletedDrinks = new ArrayList<Drink>();
depletedDrinks = new ArrayList<>();
}

for (int i = 0; i < depletedDrinksJSON.length(); i++) {
Expand Down

0 comments on commit d2e7d9e

Please sign in to comment.