本文整理汇总了Java中android.webkit.WebView.HitTestResult.getExtra方法的典型用法代码示例。如果您正苦于以下问题:Java HitTestResult.getExtra方法的具体用法?Java HitTestResult.getExtra怎么用?Java HitTestResult.getExtra使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebView.HitTestResult
的用法示例。
在下文中一共展示了HitTestResult.getExtra方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openBookmarkUrlLongClick
import android.webkit.WebView.HitTestResult; //导入方法依赖的package包/类
void openBookmarkUrlLongClick(final String url){
LightningView lv = getCurrentWebView();
HitTestResult result = lv.getWebView().getHitTestResult();
if (url != null) {
onBookmarkLongClick(url);
} else if (result != null) {
if (result.getExtra() != null) {
final String newUrl = result.getExtra();
onBookmarkLongClick(newUrl);
}
}
}
示例2: openHistoryUrlLongClick
import android.webkit.WebView.HitTestResult; //导入方法依赖的package包/类
void openHistoryUrlLongClick(final String url){
LightningView lv = getCurrentWebView();
HitTestResult result = lv.getWebView().getHitTestResult();
if (url != null) {
onHistoryLongClick(url);
} else if (result != null) {
if (result.getExtra() != null) {
final String newUrl = result.getExtra();
onHistoryLongClick(newUrl);
}
}
}
示例3: onLongClick
import android.webkit.WebView.HitTestResult; //导入方法依赖的package包/类
@Override
public boolean onLongClick(View v) {
WebView webView = (WebView) v;
HitTestResult hr = webView.getHitTestResult();
//画像が長押しされたら保存する
int type = hr.getType();
if (type == HitTestResult.IMAGE_TYPE || type == HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
//この両者の場合、Extraはいずれも画像のURLとなる
String imageUrl = hr.getExtra();
// httpで始まらないURLはダウンロード対象にできないので、無視する
if (!imageUrl.startsWith("http")) {
return false;
}
// 本来であれば、ここでダウンロードの確認を表示してあげる必要がある
// 保存先ディレクトリ
File file = new File(getActivity().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), getFilenameFromURL(imageUrl));
DownloadManager downloadManager = (DownloadManager) getActivity().getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(imageUrl));
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
request.setDestinationUri(Uri.fromFile(file));
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
downloadManager.enqueue(request);
Toast.makeText(getActivity(), "ダウンロードを開始します…", Toast.LENGTH_LONG).show();
return true;
}
return false;
}
示例4: longClickPage
import android.webkit.WebView.HitTestResult; //导入方法依赖的package包/类
@Override
/**
* handles a long click on the page, parameter String url
* is the url that should have been obtained from the WebView touch node
* thingy, if it is null, this method tries to deal with it and find a workaround
*/
public void longClickPage(final String url) {
HitTestResult result = null;
LightningView lv=getCurrentWebView();
if(lv==null){
return;
}
if(lv.getUrl().indexOf("http")<0){
longClickPageFiles(url);
return;
}
if (lv.getWebView() != null) {
result = getCurrentWebView().getWebView().getHitTestResult();
}
if (url != null) {
if (result != null) {
if (result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE
|| result.getType() == HitTestResult.IMAGE_TYPE) {
final String imageUrl = result.getExtra();
onImageLongClick(url,imageUrl);
} else {
final String extraLink = result.getExtra();
//result.
//ToastUtil.showMessage("ex:"+extraLink+" url:"+url);
onLinkLongClick(url);
}
} else {
onLinkLongClick(url);
}
} else if (result != null) {
if (result.getExtra() != null) {
final String newUrl = result.getExtra();
if (result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE
|| result.getType() == HitTestResult.IMAGE_TYPE) {
onImageLongClick(newUrl,newUrl);
//onImageLongClickExtraUrl(newUrl);
} else {
onLinkLongClick(newUrl);
}
}
}
}