Ejemplo n.º 1
0
  /**
   * 获取兴趣点列表
   *
   * @return
   */
  private List<Map<String, Object>> getData() {
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); // 创建List对象	
    WAnalysisFile readFile = new WAnalysisFile(); // 创建自定义类WAnalysisFile对象
    List<PoiPoint> poiList = readFile.getBigPoiPointList(this, tripId); // 获取兴趣点列表
    poiLists = poiList;
    for (int i = 0; i < poiList.size(); i += 1) { // 循环获取兴趣点信息
      Map<String, Object> map = new HashMap<String, Object>();
      PoiPoint poi = poiList.get(i);
      map.put("title", poi.getName()); // 兴趣点标题存储到map中
      String[] poiTel = poi.getTel().split(" "); // 兴趣点多个电话用空格分开的
      String poiTels = "";
      for (int j = 0; j < poiTel.length; j++) {
        if (poiTel.length > 2) {
          break;
        }
        poiTels = poiTels + poiTel[j] + ","; // 拼接兴趣点电话字符串
      }
      if (!"".equals(poiTels)) {
        poiTels = poiTels.substring(0, poiTels.length() - 1); // 去掉末尾的逗号
      }
      map.put("tel", poiTels); // 兴趣点电话存储到map中

      List<String> poiImgList = poi.getImgList();
      if (poiImgList.size() != 0) {
        String tripImg = poi.getImgList().get(0).split("[.]")[0] + ".jpg";
        InputStream iso = null;
        try {
          // 加载图片
          iso =
              this.getAssets()
                  .open(tripId + "/SmallRoute" + "/" + poi.getRouteId() + "/images/" + tripImg);
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        Bitmap bitmap = null;
        bitmap = BitmapFactory.decodeStream(iso);
        map.put("img", bitmap);
      } else {
        int picnum = 0;
        map.put("img", R.drawable.nocolor);
      }
      list.add(map);
    }
    return list;
  }