private void submitSolve() { try { List<ManyBook> books = mHelper.getManyBookDao().queryForAll(); for (int i = 0; i < books.size(); i++) { if (positions[i] != 0) { ManyBook book = books.get(i); book.setSolve(true); mHelper.getManyBookDao().update(book); } } finish(); } catch (Exception e) { e.printStackTrace(); } }
private void judgeSolve() { if (StringUtil.isEmpty(et_people.getText().toString().trim())) { ToastUtil.showToast(this, "请输入钱数"); return; } if (Integer.valueOf(et_people.getText().toString().trim()) == 0) { ToastUtil.showToast(this, "请输入正确的钱数"); return; } ManyBook book = null; for (int i = 0; i < books.size(); i++) { if (positions[i] != 0) { book = books.get(i); if (book.isSolve()) { solvedList.add(i); } } } if (solvedList.size() == 0) { startSolve(); } else { createDialog(); } }
private void startSolve() { int people = 1; try { people = Integer.valueOf(et_people.getText().toString().trim()); int money = 0; ManyBook book = null; for (int i = 0; i < books.size(); i++) { if (positions[i] != 0) { book = books.get(i); money += book.getMoney(); } } DecimalFormat decimalFormat = new DecimalFormat(".00"); tv_resulte.setText( "总计:" + money + "\n人数:" + people + "\n人均:" + decimalFormat.format(((float) money / (float) people))); bt_solve.setText("已均摊"); } catch (Exception e) { } }