예제 #1
0
  @Override
  protected void onResume() {
    super.onResume();
    // 先数据库

    // 读取盒子信息
    Dao<BoxDBBean, Integer> daoBoxDBBean = null;
    List<BoxDBBean> list = null;
    try {
      daoBoxDBBean = DBTool.getDBHelper().getBoxDBBeanDao();
      list = daoBoxDBBean.queryForAll();
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    initView(list);

    // 后网络
    GetBoxListBean bean = new GetBoxListBean();
    bean.setUser_id(userid);
    String sendDat = JSON.toJSONString(bean);
    HttpTranse Http = new HttpTranse();
    Http.TranseWithServer(
        this,
        "http://" + CookMasterApp.ServerIP + "/index.php/box_manager/get_list",
        sendDat,
        responseHandler);
  }
예제 #2
0
  private void fillBoxList(GetBoxListRspBean rspBean) {
    // TODO Auto-generated method stub
    mList.clear();
    GetBoxBean bean = new GetBoxBean();
    Dao<BoxDBBean, Integer> daoBoxDBBean = null;
    try {
      daoBoxDBBean = DBTool.getDBHelper().getBoxDBBeanDao();
      // 删除所有
      daoBoxDBBean.executeRaw("delete from BoxDBBean ");
      daoBoxDBBean.executeRaw("update sqlite_sequence SET seq = 0 where name = 'boxdbbean' ");
    } catch (SQLException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    for (int i = 0; i < rspBean.getBoxList().size(); i++) {
      bean = rspBean.getBoxList().get(i);
      Box boxBean = new Box();
      boxBean.setFlavorName(bean.getMaterial_name());
      boxBean.setFlavorBrand(bean.getBrand_name());
      boxBean.setBoxMac(bean.getBox_mac());
      mList.add(boxBean);
      // shujuku

      BoxDBBean BoxArg = new BoxDBBean();
      BoxArg.setBox_id(bean.getBox_id());
      BoxArg.setBox_mac(bean.getBox_mac());
      BoxArg.setBrand_id(bean.getBrand_id());
      BoxArg.setBrand_name(bean.getBrand_name());
      BoxArg.setMaterial_id(bean.getMaterial_id());
      BoxArg.setMaterial_kind_id(bean.getMaterial_kind_id());
      BoxArg.setMaterial_name(bean.getMaterial_name());
      BoxArg.setMaterial_kind_name(bean.getMaterial_kind_name());
      BoxArg.setSw_ver(bean.getSw_ver());
      BoxArg.setCorpor_name(bean.getCorpor_name());
      BoxArg.setCorpor_tel(bean.getCorpor_tel());
      BoxArg.setCorpor_addr(bean.getCorpor_addr());
      BoxArg.setCorpor_url(bean.getCorpor_url());
      // 插入一条新的记录
      try {
        daoBoxDBBean.create(BoxArg);
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    BoxAdd boxAddBean = new BoxAdd();
    mList.add(boxAddBean);
  };