本文整理汇总了Java中android.webkit.URLUtil.isNetworkUrl方法的典型用法代码示例。如果您正苦于以下问题:Java URLUtil.isNetworkUrl方法的具体用法?Java URLUtil.isNetworkUrl怎么用?Java URLUtil.isNetworkUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.URLUtil
的用法示例。
在下文中一共展示了URLUtil.isNetworkUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetch
import android.webkit.URLUtil; //导入方法依赖的package包/类
/**
* 获取多个图片,并在全部完成的时候回调
*
* @param context
* @param urls
* @param callback
*/
public static void fetch(final Context context, final LuaResourceFinder finder, final String[] urls, final LoadCallback callback) {
if (context != null && urls != null && urls.length > 0) {
final AtomicInteger count = new AtomicInteger(urls.length);
final Map<String, Drawable> result = new HashMap<String, Drawable>();
for (final String url : urls) {
if (URLUtil.isNetworkUrl(url)) {//network
final ImageProvider imageProvider = LuaView.getImageProvider();
if (imageProvider != null) {
imageProvider.preload(context, url, new DrawableLoadCallback() {
@Override
public void onLoadResult(Drawable drawable) {
result.put(url, drawable);
callCallback(count, callback, result);
}
});
}
} else {//TODO 优化成异步
if (finder != null) {
result.put(url, finder.findDrawable(url));
callCallback(count, callback, result);
}
}
}
}
}
示例2: display
import android.webkit.URLUtil; //导入方法依赖的package包/类
public void display(SimpleDraweeView view, String url, Postprocessor postprocessor) {
if (!TextUtils.isEmpty(url)) {
Uri uri;
if (URLUtil.isNetworkUrl(url)) {
uri = Uri.parse(url);
} else {
uri = Uri.fromFile(new File(url));
}
ImageRequest request = ImageRequestBuilder
.newBuilderWithSource(uri)
.setPostprocessor(postprocessor)
.setProgressiveRenderingEnabled(true)
//.setResizeOptions(new ResizeOptions(100, 100))
.setLocalThumbnailPreviewsEnabled(true)
.setRotationOptions(RotationOptions.autoRotateAtRenderTime())
.build();
controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(view.getController())
.build();
view.setController(controller);
}
}
示例3: checkURL
import android.webkit.URLUtil; //导入方法依赖的package包/类
public static boolean checkURL(CharSequence input) {
if (TextUtils.isEmpty(input)) {
return false;
}
Pattern URL_PATTERN = Patterns.WEB_URL;
boolean isURL = URL_PATTERN.matcher(input).matches();
if (!isURL) {
String urlString = input + "";
if (URLUtil.isNetworkUrl(urlString)) {
try {
new URL(urlString);
isURL = true;
} catch (Exception e) {
}
}
}
return isURL;
}
示例4: isValidSearchQueryUrl
import android.webkit.URLUtil; //导入方法依赖的package包/类
public static boolean isValidSearchQueryUrl(String url) {
String trimmedUrl = url.trim();
if (!trimmedUrl.matches("^.+?://.+?")) {
// UI hint url doesn't have http scheme, so add it if necessary
trimmedUrl = "http://" + trimmedUrl;
}
if (!URLUtil.isNetworkUrl(trimmedUrl)) {
return false;
}
if (!trimmedUrl.matches(".*%s$")) {
return false;
}
return true;
}
示例5: loadImage
import android.webkit.URLUtil; //导入方法依赖的package包/类
@Override
public void loadImage(ImageView imageView, String imagePath, int width, int height) {
if (URLUtil.isNetworkUrl(imagePath)) {
Picasso.with(imageView.getContext())
.load(imagePath)
.centerCrop()
.resize(width, height)
.into(imageView);
} else {
Picasso.with(imageView.getContext())
.load(new File(imagePath))
.centerCrop()
.resize(width, height)
.into(imageView);
}
}
示例6: decodeUri
import android.webkit.URLUtil; //导入方法依赖的package包/类
public static String decodeUri(final byte[] serviceData, final int start, final int length) {
if (start < 0 || serviceData.length < start + length)
return null;
final StringBuilder uriBuilder = new StringBuilder();
int offset = 0;
if (offset < length) {
byte b = serviceData[start + offset++];
String scheme = URI_SCHEMES.get(b);
if (scheme != null) {
uriBuilder.append(scheme);
if (URLUtil.isNetworkUrl(scheme)) {
return decodeUrl(serviceData, start + offset, length - 1, uriBuilder);
} else if ("urn:uuid:".equals(scheme)) {
return decodeUrnUuid(serviceData, start + offset, uriBuilder);
}
}
Log.w(TAG, "decodeUri unknown Uri scheme code=" + b);
}
return null;
}
示例7: encodeUri
import android.webkit.URLUtil; //导入方法依赖的package包/类
/**
* Creates the Uri string with embedded expansion codes.
*
* @param uri to be encoded
* @return the Uri string with expansion codes.
*/
public static byte[] encodeUri(String uri) {
if (uri.length() == 0) {
return new byte[0];
}
ByteBuffer bb = ByteBuffer.allocate(uri.length());
// UUIDs are ordered as byte array, which means most significant first
bb.order(ByteOrder.BIG_ENDIAN);
int position = 0;
// Add the byte code for the scheme or return null if none
Byte schemeCode = encodeUriScheme(uri);
if (schemeCode == null) {
return null;
}
String scheme = URI_SCHEMES.get(schemeCode);
bb.put(schemeCode);
position += scheme.length();
if (URLUtil.isNetworkUrl(scheme)) {
return encodeUrl(uri, position, bb);
} else if ("urn:uuid:".equals(scheme)) {
return encodeUrnUuid(uri, position, bb);
}
return null;
}
示例8: parseEmoticonName
import android.webkit.URLUtil; //导入方法依赖的package包/类
/**
* get emoticon from url
*
* @return emoticon name if exist. null if not
*/
@Nullable
public static String parseEmoticonName(@Nullable String url) {
if (TextUtils.isEmpty(url)) {
return null;
}
// url has no domain if it comes from BASE_URL server.
if (!URLUtil.isNetworkUrl(url)) {
if (url.startsWith(Api.URL_EMOTICON_IMAGE_PREFIX)) {
return url.substring(Api.URL_EMOTICON_IMAGE_PREFIX.length());
}
} else if (url.startsWith(Api.BASE_URL + Api.URL_EMOTICON_IMAGE_PREFIX)) {
return url.substring((Api.BASE_URL + Api.URL_EMOTICON_IMAGE_PREFIX).length());
} else if (url.startsWith(Api.BASE_STATIC_URL + Api.URL_EMOTICON_IMAGE_PREFIX_STATIC)) {
return url.substring((Api.BASE_STATIC_URL + Api.URL_EMOTICON_IMAGE_PREFIX_STATIC).length());
}
return null;
}
示例9: openUrlByBrowser
import android.webkit.URLUtil; //导入方法依赖的package包/类
public static boolean openUrlByBrowser(Context context, String url) {
if (TextUtils.isEmpty(url)) {
return false;
}
final String HTTP_TAG = "http://";
url = url.trim();
if (!URLUtil.isNetworkUrl(url)) {
url = HTTP_TAG + url;
}
try {
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(uri);
context.startActivity(intent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
return false;
}
return true;
}
示例10: surfaceCreated
import android.webkit.URLUtil; //导入方法依赖的package包/类
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (URLUtil.isNetworkUrl(url)) {//网络视频
try {
//播放并缓冲到本地
new Thread(new CacheNetFileR()).start();
} catch (Exception e) {
mHandler.sendEmptyMessage(NETWORK_PARSE_ERROE);
e.printStackTrace();
}
} else {
File videoFile = new File(url);
if (videoFile.exists()) {
readSize = mediaLength = videoFile.length();
System.out.println("这是本地视频,直接播放!");
mHandler.sendEmptyMessage(VIDEO_STATE_BEGIN);
}
}
}
示例11: readImage
import android.webkit.URLUtil; //导入方法依赖的package包/类
public static Bitmap readImage(Context context, Uri uri, Options opts) {
String scheme = uri.getScheme();
Bitmap bmp = null;
if (URLUtil.isNetworkUrl(uri.toString())) {
bmp = readImageWithUrl(uri.toString(), opts);
} else if (ContentResolver.SCHEME_FILE.equals(scheme)) {
bmp = readImage(uri.getPath(), opts);
} else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
InputStream in = null;
try {
in = context.getContentResolver().openInputStream(uri);
bmp = readImage(in, opts);
} catch (FileNotFoundException e) {
L.e(BitmapUtils.class, e);
} finally {
FileUtils.closeIO(in);
}
} else {
throw new IllegalArgumentException("不支持的Uri: " + uri.toString());
}
return bmp;
}
示例12: guessImageFormatC
import android.webkit.URLUtil; //导入方法依赖的package包/类
@SuppressLint("NewApi")
public static CompressFormat guessImageFormatC(String urlOrPath) {
CompressFormat format = null;
String fileName;
if (URLUtil.isNetworkUrl(urlOrPath)) {
fileName = URLUtil.guessFileName(urlOrPath, null, null);
} else if (urlOrPath.lastIndexOf('.') <= 0) {
return null;
} else {
fileName = urlOrPath;
}
fileName = fileName.toLowerCase(Locale.US);
if (fileName.endsWith(".png")) {
format = CompressFormat.PNG;
} else if (fileName.endsWith(".jpg") || fileName.endsWith(".jpeg")) {
format = CompressFormat.JPEG;
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && fileName.endsWith(".webp")) {
format = CompressFormat.WEBP;
}
return format;
}
示例13: getPreferredVideoInfo
import android.webkit.URLUtil; //导入方法依赖的package包/类
@Nullable
public VideoInfo getPreferredVideoInfo() {
if (isPreferredVideoInfo(mobileLow)) {
return mobileLow;
}
if (isPreferredVideoInfo(mobileHigh)) {
return mobileHigh;
}
if (new Config(MainApplication.instance()).isUsingVideoPipeline()) {
if (fallback != null && URLUtil.isNetworkUrl(fallback.url) &&
VideoUtil.isSupportedVideoFormat(fallback.url, AppConstants.VIDEO_FORMAT_M3U8)) {
return fallback;
}
} else {
if (isPreferredVideoInfo(fallback)) {
return fallback;
}
}
return null;
}
示例14: analysisDownloadable
import android.webkit.URLUtil; //导入方法依赖的package包/类
private boolean analysisDownloadable() {
boolean downloadUrlRight = false;
if (getDbFeed().getServers() == null || getDbFeed().getServers().isEmpty() || URLUtil
.isNetworkUrl(downURL)) {
downloadUrlRight = checkUrl(downURL);
serverStatus.put(downURL, downloadUrlRight ? 1 : 2);
} else {
int m = getDbFeed().getServers().size();
for (int i = 0; i < m; i++) {
String str = getDbFeed().getServers().get(i).concat(getDbFeed().getDownloadUrl());
downloadUrlRight = checkUrl(str);
serverStatus.put(str, downloadUrlRight ? 1 : 2);
if (downloadUrlRight) {
break;
}
}
}
return downloadUrlRight;
}
示例15: decodeUrl
import android.webkit.URLUtil; //导入方法依赖的package包/类
static String decodeUrl(byte[] serviceData) {
StringBuilder url = new StringBuilder();
int offset = 2;
byte b = serviceData[offset++];
String scheme = URI_SCHEMES.get(b);
if (scheme != null) {
url.append(scheme);
if (URLUtil.isNetworkUrl(scheme)) {
return decodeUrl(serviceData, offset, url);
} else if ("urn:uuid:".equals(scheme)) {
return decodeUrnUuid(serviceData, offset, url);
}
}
return url.toString();
}