예제 #1
0
  public ArrayList<HashMap<String, String>> getCodes() {
    if (null == mList || mList.length == 0) {
      return null;
    }

    ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

    HashMap<String, String> m;

    String code;

    for (int i = 0; i < mList.length; i++) {
      code = mList[i];

      if (null != code && !code.equals("")) {
        m = new HashMap<String, String>();

        m.put(MeterSurvey.D_ASSET_NO, code);

        m.put(MeterSurvey.IN_ROW, getRow(i) + "");

        m.put(MeterSurvey.IN_COLUMN, getColumn(i) + "");

        if (i == mSelectedIndex) {
          String name = mEdit.getUserName();

          String address = mEdit.getAddress();

          m.put(MeterSurvey.USER_NAME, name);

          m.put(MeterSurvey.USER_ADDRESS, address);
        } else {
          UserInfo ui = mUserInfos.get(code);

          if (null != ui) {
            String name = null == ui.userName ? "" : ui.userName;

            String address = null == ui.userAddress ? "" : ui.userAddress;

            m.put(MeterSurvey.USER_NAME, name);

            m.put(MeterSurvey.USER_ADDRESS, address);
          }
        }

        list.add(m);
      }
    }

    return list;
  }
예제 #2
0
  public void setSelected(int i) {
    Log.d("", "zhou -- setSelected -- i " + i);

    if (i >= getCount()) {
      return;
    }

    // 保存旧的用户信息
    if (null != mEdit) {
      String oldCode = mList[mSelectedIndex];

      Log.d("", "zhou -- setSelected -- oldcode " + oldCode);

      String name = mEdit.getUserName();

      String address = mEdit.getAddress();

      Log.d(
          "",
          "zhou -- setSelected -- old: name "
              + name
              + " address "
              + address
              + " index "
              + mSelectedIndex);

      if (null != oldCode
          && !oldCode.equals("")
          && !((null == name || name.equals("")) && (null == address || address.equals("")))) {
        Log.d("", "zhou -- setSelected -- save old " + oldCode);

        setUserInfo(oldCode, name, address);
      }
    }

    mSelectedIndex = i;

    String code = mList[mSelectedIndex];

    if (null != mEdit) {
      if (null != code) {
        UserInfo ui = mUserInfos.get(code);

        Log.d("", "zhou -- setSelected -- code " + code);

        if (null != ui) {
          Log.d(
              "",
              "zhou -- setSelected -- new : ui name "
                  + ui.userName
                  + " address "
                  + ui.userAddress
                  + " index "
                  + mSelectedIndex);

          mEdit.setUserInfo(ui.userName, ui.userAddress);
        } else {
          HashMap<String, String> meter =
              MeterSurveyDataManager.getInstance().getMeterWithAssetNo(code);

          String name = meter.get(MeterSurvey.USER_NAME);
          String address = meter.get(MeterSurvey.USER_ADDRESS);

          Log.d(
              "",
              "zhou -- setSelected -- new : db name "
                  + name
                  + " address "
                  + address
                  + " index "
                  + mSelectedIndex);

          mEdit.setUserInfo(null == name ? "" : name, null == address ? "" : address);
        }
      } else {
        mEdit.setUserInfo("", "");
      }
    }

    notifyDataSetChanged();
  }