當前位置: 首頁>>代碼示例>>Java>>正文


Java URLUtil.guessUrl方法代碼示例

本文整理匯總了Java中android.webkit.URLUtil.guessUrl方法的典型用法代碼示例。如果您正苦於以下問題:Java URLUtil.guessUrl方法的具體用法?Java URLUtil.guessUrl怎麽用?Java URLUtil.guessUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.webkit.URLUtil的用法示例。


在下文中一共展示了URLUtil.guessUrl方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: smartUrlFilter

import android.webkit.URLUtil; //導入方法依賴的package包/類
/**
 * Attempts to determine whether user input is a URL or search
 * terms.  Anything with a space is passed to search if canBeSearch is true.
 * <p/>
 * Converts to lowercase any mistakenly uppercased schema (i.e.,
 * "Http://" converts to "http://"
 *
 * @param canBeSearch If true, will return a search url if it isn't a valid
 *                    URL. If false, invalid URLs will return null
 * @return Original or modified URL
 */
@NonNull
public static String smartUrlFilter(@NonNull String url, boolean canBeSearch, String searchUrl) {
    String inUrl = url.trim();
    boolean hasSpace = inUrl.indexOf(' ') != -1;
    Matcher matcher = ACCEPTED_URI_SCHEMA.matcher(inUrl);
    if (matcher.matches()) {
        // force scheme to lowercase
        String scheme = matcher.group(1);
        String lcScheme = scheme.toLowerCase();
        if (!lcScheme.equals(scheme)) {
            inUrl = lcScheme + matcher.group(2);
        }
        if (hasSpace && Patterns.WEB_URL.matcher(inUrl).matches()) {
            inUrl = inUrl.replace(" ", "%20");
        }
        return inUrl;
    }
    if (!hasSpace) {
        if (Patterns.WEB_URL.matcher(inUrl).matches()) {
            return URLUtil.guessUrl(inUrl);
        }
    }
    if (canBeSearch) {
        return URLUtil.composeSearchUrl(inUrl,
            searchUrl, QUERY_PLACE_HOLDER);
    }
    return "";
}
 
開發者ID:XndroidDev,項目名稱:Xndroid,代碼行數:40,代碼來源:UrlUtils.java

示例2: smartUrlFilter

import android.webkit.URLUtil; //導入方法依賴的package包/類
/**
 * Attempts to determine whether user input is a URL or search
 * terms.  Anything with a space is passed to search if canBeSearch is true.
 * <p/>
 * Converts to lowercase any mistakenly uppercased schema (i.e.,
 * "Http://" converts to "http://"
 *
 * @param canBeSearch If true, will return a search url if it isn't a valid
 *                    URL. If false, invalid URLs will return null
 * @return Original or modified URL
 */
public static String smartUrlFilter(String url, boolean canBeSearch, String searchUrl) {
    String inUrl = url.trim();
    boolean hasSpace = inUrl.indexOf(' ') != -1;
    Matcher matcher = ACCEPTED_URI_SCHEMA.matcher(inUrl);
    if (matcher.matches()) {
        // force scheme to lowercase
        String scheme = matcher.group(1);
        String lcScheme = scheme.toLowerCase();
        if (!lcScheme.equals(scheme)) {
            inUrl = lcScheme + matcher.group(2);
        }
        if (hasSpace && Patterns.WEB_URL.matcher(inUrl).matches()) {
            inUrl = inUrl.replace(" ", "%20");
        }
        return inUrl;
    }
    if (!hasSpace) {
        if (Patterns.WEB_URL.matcher(inUrl).matches()) {
            return URLUtil.guessUrl(inUrl);
        }
    }
    if (canBeSearch) {
        return URLUtil.composeSearchUrl(inUrl,
                searchUrl, QUERY_PLACE_HOLDER);
    }
    return null;
}
 
開發者ID:javadtaghia,項目名稱:DeeBrowser,代碼行數:39,代碼來源:UrlUtils.java

示例3: smartUrlFilter

import android.webkit.URLUtil; //導入方法依賴的package包/類
/**
 * Attempts to determine whether user input is a URL or search
 * terms.  Anything with a space is passed to search if canBeSearch is true.
 *
 * Converts to lowercase any mistakenly uppercased schema (i.e.,
 * "Http://" converts to "http://"
 *
 * @param canBeSearch If true, will return a search url if it isn't a valid
 *                    URL. If false, invalid URLs will return null
 * @return Original or modified URL
 *
 */
public static String smartUrlFilter(String url, boolean canBeSearch) {
    String inUrl = url.trim();
    boolean hasSpace = inUrl.indexOf(' ') != -1;

    Matcher matcher = ACCEPTED_URI_SCHEMA.matcher(inUrl);
    if (matcher.matches()) {
        // force scheme to lowercase
        String scheme = matcher.group(1);
        String lcScheme = scheme.toLowerCase();
        if (!lcScheme.equals(scheme)) {
            inUrl = lcScheme + matcher.group(2);
        }
        if (hasSpace && Patterns.WEB_URL.matcher(inUrl).matches()) {
            inUrl = inUrl.replace(" ", "%20");
        }
        return inUrl;
    }
    if (!hasSpace) {
        if (Patterns.WEB_URL.matcher(inUrl).matches()) {
            return URLUtil.guessUrl(inUrl);
        }
    }
    if (canBeSearch) {
        return URLUtil.composeSearchUrl(inUrl,
                QUICKSEARCH_G, QUERY_PLACE_HOLDER);
    }
    return null;
}
 
開發者ID:dailystudio,項目名稱:devbricks,代碼行數:41,代碼來源:UrlUtils.java

示例4: a

import android.webkit.URLUtil; //導入方法依賴的package包/類
public final void a(String paramString1, String paramString2, int paramInt, lbb paramlbb)
{
  if (paramInt == -2) {
    return;
  }
  if (TextUtils.isEmpty(paramString1))
  {
    int k = ev.H;
    paramlbb.a(g().getString(k));
    return;
  }
  if (TextUtils.isEmpty(paramString2))
  {
    int j = ev.J;
    paramlbb.b(g().getString(j));
    return;
  }
  String str1 = URLUtil.guessUrl(paramString2);
  if ((Patterns.WEB_URL.matcher(str1).matches()) && ((URLUtil.isHttpUrl(str1)) || (URLUtil.isHttpsUrl(str1)))) {}
  for (String str2 = str1; str2 == null; str2 = null)
  {
    int i = ev.I;
    paramlbb.b(g().getString(i));
    return;
  }
  odq localodq1 = (odq)this.c.get(this.ab);
  if ((!mfx.a(localodq1.b, paramString1)) || (!mfx.a(localodq1.a, str2)))
  {
    this.c.remove(this.ab);
    odq localodq2 = new odq();
    localodq2.b = paramString1;
    localodq2.a = str2;
    this.c.add(this.ab, localodq2);
    w();
    this.d.notifyDataSetChanged();
    this.a = true;
  }
  paramlbb.d.dismiss();
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:40,代碼來源:laz.java

示例5: guessUrl

import android.webkit.URLUtil; //導入方法依賴的package包/類
public static String guessUrl(String url){
    String returnurl = URLUtil.guessUrl(url);

    return returnurl;
}
 
開發者ID:michaelachmann,項目名稱:LnkShortener,代碼行數:6,代碼來源:UrlManager.java

示例6: getBaseURL

import android.webkit.URLUtil; //導入方法依賴的package包/類
protected String getBaseURL() {
	return URLUtil.guessUrl(this.url);
}
 
開發者ID:ilesinge,項目名稱:scuttloid,代碼行數:4,代碼來源:ScuttleAPI.java


注:本文中的android.webkit.URLUtil.guessUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。