コード例 #1
0
  private static final void gatherMapLinks(ArrayList<LinkSpec> links, Spannable s) {
    String string = s.toString();
    String address;
    int base = 0;

    while ((address = WebView.findAddress(string)) != null) {
      int start = string.indexOf(address);

      if (start < 0) {
        break;
      }

      LinkSpec spec = new LinkSpec();
      int length = address.length();
      int end = start + length;

      spec.start = base + start;
      spec.end = base + end;
      string = string.substring(end);
      base += end;

      String encodedAddress = null;

      try {
        encodedAddress = URLEncoder.encode(address, "UTF-8");
      } catch (UnsupportedEncodingException e) {
        continue;
      }

      spec.url = "geo:0,0?q=" + encodedAddress;
      links.add(spec);
    }
  }
コード例 #2
0
  /**
   * Simple event to raise when the component is clicked. Implementation of
   * AdapterView.OnItemClickListener
   */
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Spannable item = (Spannable) parent.getAdapter().getItem(position);
    this.selection = item.toString();
    this.selectionIndex = adapterCopy.getPosition(item) + 1; // AI lists are 1-based

    AfterPicking();
  }
コード例 #3
0
  public void setInfoString(Spannable value) {
    if (value != null && value.toString().trim().length() > 0) {
      Object[] result =
          getBreakerText(
              value.toString(),
              getTextWidth()
                  - mStartTimeBounds.width()
                  - ProgramTableLayoutConstants.TIME_TITLE_GAP,
              ProgramTableLayoutConstants.NOT_EXPIRED_PICTURE_COPYRIGHT_PAINT);

      String all = result[0].toString();

      String[] lines = all.split("\n");

      mCategoriesString = new ColorLine[lines.length];

      HashMap<String, Integer> categoryColorMap = IOUtils.loadCategoryColorMap(getContext());

      for (int i = 0; i < lines.length; i++) {
        mCategoriesString[i] = new ColorLine();

        String[] lineParts = lines[i].split(",");

        for (int j = 0; j < lineParts.length - 1; j++) {
          mCategoriesString[i].addEntry(
              new ColorEntry(categoryColorMap.get(lineParts[j].trim()), lineParts[j], true));
        }

        if (lineParts.length > 0) {
          mCategoriesString[i].addEntry(
              new ColorEntry(
                  categoryColorMap.get(lineParts[lineParts.length - 1].trim()),
                  lineParts[lineParts.length - 1],
                  (i != lines.length - 1)));
        }
      }

      mSuperSmallCount += (Integer) result[1];
    }
  }