当前位置: 首页>>代码示例>>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;未经允许,请勿转载。