コード例 #1
0
  /*
   * follow editText entry as a url
   */
  private void addAsUrl(final String entry) {
    if (TextUtils.isEmpty(entry)) {
      return;
    }

    // normalize the url and prepend protocol if not supplied
    final String normUrl;
    if (!entry.contains("://")) {
      normUrl = UrlUtils.normalizeUrl("http://" + entry);
    } else {
      normUrl = UrlUtils.normalizeUrl(entry);
    }

    // if this isn't a valid URL, add original entry as a tag
    if (!URLUtil.isNetworkUrl(normUrl)) {
      addAsTag(entry);
      return;
    }

    // make sure it isn't already followed
    if (ReaderBlogTable.isFollowedBlogUrl(normUrl) || ReaderBlogTable.isFollowedFeedUrl(normUrl)) {
      ToastUtils.showToast(this, R.string.reader_toast_err_already_follow_blog);
      return;
    }

    // URL is valid, so follow it
    performAddUrl(normUrl);
  }