private void setAlbumart() { playlistTitleView.setText(playlistName); if(albumPath == null){ albumArtSmall.setImageResource(R.drawable.placeholder_disk_210); }else { albumArtSmall.setImageURI(Uri.parse(albumPath)); } try { if (isLocalPlaylist && !URLUtil.isNetworkUrl(albumPath)) { new setBlurredAlbumArt().execute(ImageUtils.getArtworkQuick(PlaylistActivity.this, Uri.parse(albumPath), 300, 300)); L.D(d, TAG, "albumpath = " + albumPath); } else { //drawable = Drawable.createFromStream( new URL(albumPath).openStream(),"src"); ImageRequest imageRequest = ImageRequest.fromUri(albumPath); CacheKey cacheKey = DefaultCacheKeyFactory.getInstance() .getEncodedCacheKey(imageRequest); BinaryResource resource = ImagePipelineFactory.getInstance() .getMainDiskStorageCache().getResource(cacheKey); File file = ((FileBinaryResource) resource).getFile(); if (file != null) new setBlurredAlbumArt().execute(ImageUtils.getArtworkQuick(file, 300, 300)); } } catch (Exception e) { e.printStackTrace(); } }
String location = responseHeaders.getLocation(); if (!URLUtil.isNetworkUrl(location)) { String oldUrl = oldRequest.url(); try {
if (TextUtils.isEmpty(location)) return null; if (URLUtil.isNetworkUrl(location)) { return newBuilder(location).build();
private void interceptLink(TextView view) { view.setMovementMethod(LinkMovementMethod.getInstance()); CharSequence text = view.getText(); if (text instanceof Spannable) { Spannable spannable = (Spannable) text; URLSpan[] spans = spannable.getSpans(0, text.length(), URLSpan.class); if (spans.length == 0) { return; } SpannableStringBuilder ssb = new SpannableStringBuilder(text); for (URLSpan urlSpan : spans) { final String url = urlSpan.getURL(); if (URLUtil.isNetworkUrl(url)) { ClickableSpan clickableSpan = new ClickableSpan() { @Override public void onClick(View widget) { WebActivity.startActivity(getActivity(), url); } }; ssb.setSpan(clickableSpan, spannable.getSpanStart(urlSpan) , spannable.getSpanEnd(urlSpan), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } } view.setText(ssb); } }
@Override public WebResourceResponse intercept(final WebView view, final Uri uri, final Map<String, String> headers) { final String url = uri.toString(); if (!URLUtil.isNetworkUrl(url)) { logger.warn("Non-HTTP request ignored: " + url); return null;
private WPEditImageSpan createWPEditImageSpan(Context context, MediaFile mediaFile) { if (!URLUtil.isNetworkUrl(mediaFile.getFileURL())) { return createWPEditImageSpanLocal(context, mediaFile); } else { return createWPEditImageSpanRemote(context, mediaFile); } }
if (URLUtil.isNetworkUrl(result)) { finish(); return;
public void doDownload() { if (mIsCancelled) { // if the download has been cancelled, do not download // this image, but start the next one if (!queuedDownLoaderRequests.isEmpty() && runningDownLoaderRequests.size() < maxDownloads) { LoaderRequest d = queuedDownLoaderRequests.remove(0); d.doDownload(); } return; } ImageView imageView = mImageViewRef.get(); if (imageView != null && imageView.getTag(DRAWABLE_DOWNLOAD_TAG) == this && URLUtil.isNetworkUrl(uri)) { mDrawableDownloaderTask = new ApptentiveDownloaderTask(imageView, this); try { ApptentiveLog.v(UTIL, "ApptentiveAttachmentLoader doDownload: " + uri); // Conversation token is needed if the download url is a redirect link from an Apptentive endpoint if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mDrawableDownloaderTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, uri, diskCacheFilePath, conversationToken); } else { mDrawableDownloaderTask.execute(uri, diskCacheFilePath, conversationToken); } } catch (RejectedExecutionException e) { } runningDownLoaderRequests.add(this); filesBeingDownloaded.add(diskCacheFilePath); } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { String url = request.getUrl().toString(); if (!URLUtil.isNetworkUrl(url)) { return super.shouldInterceptRequest(view, request); } // Request and add an authorization header for HTTPS resource requests. // Use https:// when requesting the auth header, in case the resource is incorrectly using http://. // If an auth header is returned, force https:// for the actual HTTP request. String authHeader = mAuthHeaderRequestListener.onAuthHeaderRequested(UrlUtils.makeHttps(url)); if (StringUtils.notNullStr(authHeader).length() > 0) { try { url = UrlUtils.makeHttps(url); // Keep any existing request headers from the WebResourceRequest Map<String, String> headerMap = request.getRequestHeaders(); for (Map.Entry<String, String> entry : mHeaderMap.entrySet()) { headerMap.put(entry.getKey(), entry.getValue()); } headerMap.put("Authorization", authHeader); HttpURLConnection conn = HTTPUtils.setupUrlConnection(url, headerMap); return new WebResourceResponse(conn.getContentType(), conn.getContentEncoding(), conn.getInputStream()); } catch (IOException e) { AppLog.e(T.EDITOR, e); } } return super.shouldInterceptRequest(view, request); }
/** * Compatibility method for API < 21 */ @SuppressWarnings("deprecation") @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { if (!URLUtil.isNetworkUrl(url)) { return super.shouldInterceptRequest(view, url); } // Request and add an authorization header for HTTPS resource requests. // Use https:// when requesting the auth header, in case the resource is incorrectly using http://. // If an auth header is returned, force https:// for the actual HTTP request. String authHeader = mAuthHeaderRequestListener.onAuthHeaderRequested(UrlUtils.makeHttps(url)); if (StringUtils.notNullStr(authHeader).length() > 0) { try { url = UrlUtils.makeHttps(url); Map<String, String> headerMap = new HashMap<>(mHeaderMap); headerMap.put("Authorization", authHeader); HttpURLConnection conn = HTTPUtils.setupUrlConnection(url, headerMap); return new WebResourceResponse(conn.getContentType(), conn.getContentEncoding(), conn.getInputStream()); } catch (IOException e) { AppLog.e(T.EDITOR, e); } } return super.shouldInterceptRequest(view, url); } });
public Url location(String location) { if (TextUtils.isEmpty(location)) return null; if (URLUtil.isNetworkUrl(location)) { return newBuilder(location).build();
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (URLUtil.isNetworkUrl(url)) { if (mPresenter.isUseSystemBrowser()) { NavigationUtil.openInBrowser(getActivity(), url); } else { ((SupportActivity) getContext()).findFragment(MainFragment.class) .start(WebViewFragment.newInstance(url, "")); } } return true; }
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (URLUtil.isNetworkUrl(url)) { dismiss(); if (mPresenter.isUseSystemBrowser()) { NavigationUtil.openInBrowser(getActivity(), url); } else { ((SupportActivity) getContext()).findFragment(MainFragment.class) .start(WebViewFragment.newInstance(url, "")); } } return true; }
@Override public void run() { if (URLUtil.isNetworkUrl(mediaUrl)) { String mediaId = mediaFile.getMediaId(); if (mediaFile.isVideo()) { String posterUrl = Utils.escapeQuotes(StringUtils.notNullStr(mediaFile.getThumbnailURL())); String videoPressId = ShortcodeUtils.getVideoPressIdFromShortCode( mediaFile.getVideoPressShortCode()); mWebView.execJavaScriptFromString("ZSSEditor.insertVideo('" + safeMediaUrl + "', '" + posterUrl + "', '" + videoPressId + "');"); } else { mWebView.execJavaScriptFromString("ZSSEditor.insertImage('" + safeMediaUrl + "', '" + mediaId + "');"); } mActionStartedAt = System.currentTimeMillis(); } else { String id = mediaFile.getMediaId(); if (mediaFile.isVideo()) { String posterUrl = Utils.escapeQuotes(StringUtils.notNullStr(mediaFile.getThumbnailURL())); mWebView.execJavaScriptFromString("ZSSEditor.insertLocalVideo(" + id + ", '" + posterUrl + "');"); mUploadingMedia.put(id, MediaType.VIDEO); } else { mWebView.execJavaScriptFromString("ZSSEditor.insertLocalImage(" + id + ", '" + safeMediaUrl + "');"); mUploadingMedia.put(id, MediaType.IMAGE); } } } });
if (mImageLoader != null && URLUtil.isNetworkUrl(mImageUrl)) { loadWPImageSpanThumbnail(mMediaFile, mImageUrl, mImageLoader);