コード例 #1
0
  private Matirial getMatData(int id) {

    for (Matirial mat : listALLMat) {
      if (mat.getMatId() == id) {
        Log.v("id = ", mat.getMatId() + "");
        return mat;
      }
    }

    return new Matirial();
  }
コード例 #2
0
  private Matirial checkStockRefrigerator(ReciveDetail use) {

    int isNotHaveInRefrag = 0;
    for (Matirial obj : listMatirial) { // obj is mat in Refrigerator
      if (use.getMatId() == obj.getMatId()) {
        if (use.getAmount() > obj.getAmountTotal()) {
          obj.setAmount(use.getAmount() - obj.getAmountTotal()); // amount balance
          return obj;
        }
      }
      if (use.getMatId() != obj.getMatId()) {
        isNotHaveInRefrag++;
      }
    }
    if (isNotHaveInRefrag == listMatirial.size()) {
      // if mat is not have in my refragerator
      Matirial mat = getMatData(use.getMatId());
      //            mat.setMatId(use.getMatId());
      mat.setAmount(use.getAmount());
      return mat;
    }
    return null;
  }