本文整理汇总了Java中android.webkit.WebView.HitTestResult类的典型用法代码示例。如果您正苦于以下问题:Java HitTestResult类的具体用法?Java HitTestResult怎么用?Java HitTestResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HitTestResult类属于android.webkit.WebView包,在下文中一共展示了HitTestResult类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: posterView
import android.webkit.WebView.HitTestResult; //导入依赖的package包/类
public void posterView(View v) {
if (!posterLoaded) {
posterView = (WebView) findViewById(R.id.posterView);
if (posterURL.isEmpty() || posterURL.equalsIgnoreCase("null")) {
if (!fanartURL.isEmpty() && !fanartURL.equalsIgnoreCase("null")) {
posterURL = fanartURL;
} else {
return;
}
}
if (fanartURL.isEmpty() || fanartURL.equalsIgnoreCase("null"))
fanartURL = posterURL;
posterView.getSettings().setBuiltInZoomControls(true);
posterView.getSettings().setLoadWithOverviewMode(true);
posterView.getSettings().setUseWideViewPort(true);
posterView.loadData(getURL(posterURL, "ds:fanart"), "text/html", "UTF-8");
posterView.setBackgroundColor(Color.BLACK);
posterView.setInitialScale(1);
posterView.setOverScrollMode(View.OVER_SCROLL_NEVER);
posterView.setWebViewClient(new WebViewHandler());
posterView.setLongClickable(true);
posterView.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View arg0) {
HitTestResult hit = posterView.getHitTestResult();
if (hit.getType() == HitTestResult.IMAGE_TYPE ||
hit.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
Intent extViewIntent = new Intent();
extViewIntent.setAction(Intent.ACTION_VIEW);
extViewIntent.setDataAndType(Uri.parse(hit.getExtra()), "image/*");
startActivity(extViewIntent);
}
return true;
}
});
posterLoaded = true;
}
posterView.setVisibility(View.VISIBLE);
}
示例4: 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;
}
示例5: onWebViewLongClicked
import android.webkit.WebView.HitTestResult; //导入依赖的package包/类
@LongClick(R.id.webView)
protected boolean onWebViewLongClicked() {
HitTestResult result = webView.getHitTestResult();
if (result != null && (result.getType() == HitTestResult.IMAGE_TYPE || result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE)) {
return showImageTitle(result.getExtra());
}
return false;
}
示例6: 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);
}
}
}
}