当前位置: 首页>>代码示例>>Java>>正文


Java URLUtil.isNetworkUrl方法代码示例

本文整理汇总了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);
                }
            }
        }
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:33,代码来源:ImageUtil.java

示例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);

    }

}
 
开发者ID:zhonglikui,项目名称:cardinalsSample,代码行数:27,代码来源:FrescoManager.java

示例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;
}
 
开发者ID:zzzmobile,项目名称:VideoDownloader-Android,代码行数:19,代码来源:iUtils.java

示例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;
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:18,代码来源:UrlUtils.java

示例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);
    }
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:17,代码来源:PicassoAlbumLoader.java

示例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;
}
 
开发者ID:NordicSemiconductor,项目名称:Android-nRF-Beacon-for-Eddystone,代码行数:22,代码来源:ParserUtils.java

示例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;
}
 
开发者ID:NordicSemiconductor,项目名称:Android-nRF-Beacon-for-Eddystone,代码行数:32,代码来源:ParserUtils.java

示例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;
}
 
开发者ID:ykrank,项目名称:S1-Next,代码行数:23,代码来源:Api.java

示例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;
}
 
开发者ID:Android-Jungle,项目名称:android-jungle-framework,代码行数:25,代码来源:MiscUtils.java

示例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);
        }
    }
}
 
开发者ID:Grrsun,项目名称:meipaiAll,代码行数:21,代码来源:MeipaiDetailActivity.java

示例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;
}
 
开发者ID:WeiChou,项目名称:Wei.Lib2A,代码行数:23,代码来源:BitmapUtils.java

示例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;
}
 
开发者ID:WeiChou,项目名称:Wei.Lib2A,代码行数:22,代码来源:BitmapUtils.java

示例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;
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:21,代码来源:EncodedVideos.java

示例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;
}
 
开发者ID:lisicnu,项目名称:easyDownload,代码行数:25,代码来源:DownloadPool.java

示例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();
}
 
开发者ID:etsy,项目名称:divertsy-client,代码行数:16,代码来源:UrlUtils.java


注:本文中的android.webkit.URLUtil.isNetworkUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。