本文整理了Java中android.webkit.WebView.copyBackForwardList()
方法的一些代码示例,展示了WebView.copyBackForwardList()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.copyBackForwardList()
方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:copyBackForwardList
暂无
代码示例来源:origin: cymcsg/UltimateAndroid
/**
* Get a historical list of webview
* @param webView
* @return
*/
public static WebBackForwardList getHistoricalList(WebView webView) {
return webView.copyBackForwardList();
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
@Override
public void onBackPressed() {
if (mWebView.canGoBack() && mWebView.copyBackForwardList().getSize() > 0
&& !mWebView.getUrl().equals(mWebView.copyBackForwardList()
.getItemAtIndex(0).getOriginalUrl())) {
mWebView.goBack();
} else {
finish();
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldCopyBackForwardListWhenPopulated() {
webView.loadUrl("foo1.bar");
webView.loadUrl("foo2.bar");
WebBackForwardList historyList = webView.copyBackForwardList();
assertThat(historyList.getSize()).isEqualTo(2);
assertThat(historyList.getCurrentItem().getUrl()).isEqualTo("foo2.bar");
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldReturnCopyFromCopyBackForwardList() {
WebBackForwardList historyList = webView.copyBackForwardList();
// Adding history after copying should not affect the copy.
webView.loadUrl("foo1.bar");
webView.loadUrl("foo2.bar");
assertThat(historyList.getSize()).isEqualTo(0);
assertThat(historyList.getCurrentIndex()).isEqualTo(-1);
assertThat(historyList.getCurrentItem()).isNull();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldCopyBackForwardListWhenEmpty() {
WebBackForwardList historyList = webView.copyBackForwardList();
assertThat(historyList.getSize()).isEqualTo(0);
assertThat(historyList.getCurrentIndex()).isEqualTo(-1);
assertThat(historyList.getCurrentItem()).isNull();
}
代码示例来源:origin: Justson/AgentWeb
public void onPageFinished(WebView view) {
if (!mIsOnReceivedTitle && mWebChromeClient != null) {
WebBackForwardList list = null;
try {
list = view.copyBackForwardList();
} catch (NullPointerException e) {
if (LogUtils.isDebug()) {
e.printStackTrace();
}
}
if (list != null
&& list.getSize() > 0
&& list.getCurrentIndex() >= 0
&& list.getItemAtIndex(list.getCurrentIndex()) != null) {
String previousTitle = list.getItemAtIndex(list.getCurrentIndex()).getTitle();
mWebChromeClient.onReceivedTitle(view, previousTitle);
}
}
}
代码示例来源:origin: stackoverflow.com
public class BackButtonListener implements View.OnKeyListener {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
WebView webView = (WebView) v;
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
WebBackForwardList backstack = webView.copyBackForwardList();
int currentIndex = backstack.getCurrentIndex();
int i = -1;
while (webView.canGoBackOrForward(i)) {
if (!backstack.getItemAtIndex(currentIndex + i).getUrl().equals("about:blank")) {
webView.goBackOrForward(i);
return true;
}
i--;
}
webView.goBack();
return true;
}
}
return false;
}
}
内容来源于网络,如有侵权,请联系作者删除!