コード例 #1
0
        // 获取到饲料配方类型成功
        public void onSuccess(String result) {
          // TODO Auto-generated method stub
          EntityDataPageVo edv = null;
          try {
            edv = new Gson().fromJson(result, new TypeToken<EntityDataPageVo>() {}.getType());
            if ((edv != null) && (edv.getErrorCode().equals(CommonResultVo.ERROR_CODE_SUCCESS))) {
              List<NutritionVo> temps1 =
                  new ArrayList<NutritionVo>(); // (ArrayList<NutritionVo>) edv.data;
              // List<String> temps=new ArrayList<String>();
              try {
                temps1 = JsonUtil.fromJsonArray(JsonUtil.toJson(edv.data), NutritionVo.class);
              } catch (Exception e) {
              }
              if (temps1 != null && temps1.size() > 0) {
                listNus.addAll(temps1);
              } else {
                NutritionVo nv = new NutritionVo();
                nv.id = null;
                nv.name = "无";
                nv.systemUnitNum = "无";
                nv.systemUnitName = "无";
                listNus.add(nv);
              }

              nuAdapter =
                  new NutritionListAdapter(
                      listNus,
                      getApplicationContext(),
                      R.layout.fragment_fromula_nutrition_list_item);
              nuListView.setAdapter(nuAdapter);
              fixListViewHeight(nuListView);
              // 数据加载完成改变一下scrollview的显示位置
              sv.scrollTo(0, 0);
            } else {
              UIHelper.ToastMessage(
                  ActivityFormulaArtificial2.this, "获取配方营养素失败" + edv.getErrorMsg());
            }
          } catch (Exception e) {
            e.printStackTrace();
            UIHelper.ToastMessage(
                ActivityFormulaArtificial2.this, "获取配方营养素失败,请联系管理员:" + e.getMessage());
          }
          // UIHelper.ToastMessage(_context,"总条数=" + result + "");
        }
コード例 #2
0
        @Override
        public void onSuccess(String result) {
          // TODO Auto-generated method stub
          EntityDataPageVo edv = null;
          try {
            edv = new Gson().fromJson(result, new TypeToken<EntityDataPageVo>() {}.getType());
            if ((edv != null) && (edv.getErrorCode().equals(CommonResultVo.ERROR_CODE_SUCCESS))) {

              // List<FeedVo> temps2 = (ArrayList<FeedVo>) edv.data;
              List<FeedVo> temps1 = new ArrayList<FeedVo>();
              try {
                temps1 = JsonUtil.fromJsonArray(JsonUtil.toJson(edv.data), FeedVo.class);
              } catch (Exception e) {
              }

              if (temps1 == null
                  || temps1.size() == 0) { // mAdapterMyCreate.notifyDataSetChanged();
                Toast.makeText(ActivityFormulaArtificial2.this, "没有更多数据了", Toast.LENGTH_SHORT)
                    .show();
              } else {
                mfs.addAll(temps1);
                mfsa = new String[mfs.size()];
                mfsb = new boolean[mfs.size()];
                for (int i = 0; i < mfs.size(); i++) {
                  mfsa[i] = mfs.get(i).name;
                  mfsb[i] = false;
                }
              }

            } else {
              UIHelper.ToastLongMessage(
                  ActivityFormulaArtificial2.this, "获取饲料失败" + edv.getErrorMsg());
            }
          } catch (Exception e) {
            e.printStackTrace();
            // mStrings.addAll(temps);
            UIHelper.ToastLongMessage(
                ActivityFormulaArtificial2.this, "获取饲料失败,请联系管理员:" + e.getMessage());
          }
        }
コード例 #3
0
  private boolean checkValue() {
    String msg = "";

    if (StringUtils.isEmpty(mUserName)) {
      msg = getString(R.string.login_check_account);
      // metAccount.setError("");
      metAccount.requestFocus();
      UIHelper.ToastMessage(getApplicationContext(), msg);
      return false;
    }

    if (StringUtils.isEmpty(mPassword)) {
      msg = getString(R.string.login_check_password);

      // metPassword.setError("");
      metPassword.requestFocus();
      UIHelper.ToastMessage(getApplicationContext(), msg);
      return false;
    }

    return true;
  }
コード例 #4
0
 @Override
 public void onCancel() {
   // TODO Auto-generated method stub
   UIHelper.ToastMessage(ActivityFormulaArtificial2.this, "获取配方营养素退出");
 }
コード例 #5
0
 @Override
 public void onFailure(int error, String msg) {
   UIHelper.ToastMessage(ActivityFormulaArtificial2.this, "获取配方营养素失败" + msg);
 }
コード例 #6
0
 @Override
 public void onFailure(int error, String msg) {
   // TODO Auto-generated method stub
   UIHelper.ToastMessage(ActivityFormulaArtificial2.this, "获取饲料失败" + msg);
 }
コード例 #7
0
 private void excute() {
   try {
     // 获取配方所含营养素组成
     List<ArtificialNur> formulaNur = mPfDb.getFormulaNurs(ff.id + "");
     if (formulaNur != null && formulaNur.size() > 0) {
       if (feedids != null && feedids.length() > 0) {
         // 遍历配方含的营养素组成,这里只取第一个
         for (int f = 0; f < 1; f++) {
           ArtificialNur fn = formulaNur.get(f);
           try {
             // 获取在指定饲料中的,营养素大于number跟小于number的,饲料id的列表
             List<Long> maxFeedIds =
                 mPfDb.getMaxFeedIds(
                     feedids.substring(0, feedids.length() - 1), fn.Cid, fn.UnitNumber);
             List<Long> minFeedIds =
                 mPfDb.getMinFeedIds(
                     feedids.substring(0, feedids.length() - 1), fn.Cid, fn.UnitNumber);
             // 存distinct的feedid
             List<Long> distinctfeedids = new ArrayList<Long>();
             for (Long id : maxFeedIds) {
               if (!distinctfeedids.contains(id)) {
                 distinctfeedids.add(id);
               }
             }
             for (Long id : minFeedIds) {
               if (!distinctfeedids.contains(id)) {
                 distinctfeedids.add(id);
               }
             }
             // 将大于跟小于的饲料列表数目对齐
             if (maxFeedIds != null && maxFeedIds.size() > 0) {
               if (minFeedIds != null && minFeedIds.size() > 0) {
                 if (maxFeedIds.size() > minFeedIds.size()) {
                   Long temp = minFeedIds.get(0);
                   for (int i = 0; i < (maxFeedIds.size() - minFeedIds.size()); i++) {
                     minFeedIds.add(temp);
                   }
                 } else {
                   Long temp = maxFeedIds.get(0);
                   for (int i = 0; i < (minFeedIds.size() - maxFeedIds.size()); i++) {
                     maxFeedIds.add(temp);
                   }
                 }
                 // 拿一个总的feedid列表
                 List<Long> feeds = new ArrayList<Long>();
                 for (Long id : maxFeedIds) {
                   feeds.add(id);
                 }
                 for (Long id : minFeedIds) {
                   feeds.add(id);
                 }
                 // 计算比例中间过程,获取差值
                 // List<ArtificialNur> maxFeedNur=new ArrayList<ArtificialNur>();
                 // List<ArtificialNur> minFeedNur=new ArrayList<ArtificialNur>();
                 List<ArtificialNur> feedNur = new ArrayList<ArtificialNur>();
                 double totalNumber = 0;
                 for (Long id : feeds) {
                   try {
                     ArtificialNur temp = mPfDb.getAri(id, fn.Cid);
                     if (temp != null) {
                       temp.UnitNumber = Math.abs(fn.UnitNumber - temp.UnitNumber);
                       totalNumber += temp.UnitNumber;
                       feedNur.add(temp);
                     }
                   } catch (Exception e) {
                   }
                 }
                 // 计算比例
                 perFeedNur = new ArrayList<ArtificialNur>();
                 for (int i = 0; i < feedNur.size(); i++) {
                   try {
                     ArtificialNur temp = (ArtificialNur) feedNur.get(i).clone();
                     ArtificialNur temp1 = feedNur.get(feedNur.size() - i - 1);
                     temp.UnitNumber = temp1.UnitNumber / totalNumber;
                     perFeedNur.add(temp);
                   } catch (Exception e) {
                   }
                 }
                 // 合并重复饲料
                 for (Long id : distinctfeedids) {
                   try {
                     ArtificialNur tempav = new ArtificialNur();
                     double temp = 0;
                     for (ArtificialNur av : perFeedNur) {
                       try {
                         if (id == av.Mid) {
                           tempav = (ArtificialNur) av.clone();
                           temp += av.UnitNumber;
                         }
                       } catch (Exception e) {
                       }
                     }
                     tempav.UnitNumber = temp;
                     if (tempav != null && tempav.Mid > 0) {
                       arFeedNur.add(tempav);
                     }
                   } catch (Exception e) {
                   }
                 }
                 if (arFeedNur != null && arFeedNur.size() == 0) {
                   ArtificialNur temp = new ArtificialNur();
                   temp.Mname = "无";
                   temp.UnitNumber = 0;
                   arFeedNur.add(temp);
                 }
                 // 绑定数据展示控件
                 arFeedAdapter =
                     new ArtificialAdapter(
                         arFeedNur, getApplicationContext(), R.layout.item_list_artificial);
                 lvFormulaAr.setAdapter(arFeedAdapter);
                 fixListViewHeight(lvFormulaAr);
                 // 数据加载完成改变一下scrollview的显示位置
                 sv.scrollTo(0, 0);
               } else {
                 List<ArtificialNur> xx = mPfDb.getMinFeedNurs(fn.Cid, fn.UnitNumber);
                 if (xx != null && xx.size() > 0) {
                   String str = "";
                   for (ArtificialNur x : xx) {
                     str = str + x.Mname + ",";
                   }
                   UIHelper.ToastLongMessage(
                       ActivityFormulaArtificial2.this,
                       "当前选择的饲料:" + fn.Cname + "含量过高,请将" + str + "一种或者几种选入!");
                 } else {
                   UIHelper.ToastLongMessage(
                       ActivityFormulaArtificial2.this,
                       "由于配方的" + fn.Cname + "含量过低,数据库无法生成合适的饲料配比!");
                 }
               }
             } else {
               List<ArtificialNur> xx = mPfDb.getMaxFeedNurs(fn.Cid, fn.UnitNumber);
               if (xx != null && xx.size() > 0) {
                 String str = "";
                 for (ArtificialNur x : xx) {
                   str = str + x.Mname + ",";
                 }
                 UIHelper.ToastLongMessage(
                     ActivityFormulaArtificial2.this,
                     "当前选择的饲料:" + fn.Cname + "含量过低,请将" + str + "一种或者几种选入!");
               } else {
                 UIHelper.ToastLongMessage(
                     ActivityFormulaArtificial2.this, "由于配方的" + fn.Cname + "含量过高,数据库无法生成合适的饲料配比!");
               }
             }
           } catch (Exception e) {
           }
         }
       } else {
         UIHelper.ToastLongMessage(ActivityFormulaArtificial2.this, "请选择两种以上的饲料!");
       }
     } else {
       UIHelper.ToastLongMessage(ActivityFormulaArtificial2.this, "没有获取到该配方的营养素组成情况,请重新选择配方!");
     }
   } catch (Exception e) {
     UIHelper.ToastLongMessage(
         ActivityFormulaArtificial2.this, "智能计算出现问题,请联系管理员:" + e.getMessage());
   }
 }