Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String productName = sale_obj.getString("name");
- double total = sale_obj.getDouble("price");
- int index = product_labels_1.indexOf(productName);
- if (index < 0) {
- // product doesnt exist in product_labels_1
- product_labels_1.add(productName);
- product_values_1.add(new Entry((float) total, product_labels_1.size() - 1));
- } else {
- // read the current total
- int current_total = (int) groupedProducts.getDouble(productName);
- // increment by the total
- total = current_total + total;
- product_values_1.set(index, new Entry((float) total, index));
- }
- groupedProducts.put(productName, total);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement