本文整理汇总了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 "";
}
示例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;
}
示例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;
}
示例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();
}
示例5: guessUrl
import android.webkit.URLUtil; //导入方法依赖的package包/类
public static String guessUrl(String url){
String returnurl = URLUtil.guessUrl(url);
return returnurl;
}
示例6: getBaseURL
import android.webkit.URLUtil; //导入方法依赖的package包/类
protected String getBaseURL() {
return URLUtil.guessUrl(this.url);
}