本文整理匯總了Java中android.webkit.WebBackForwardList類的典型用法代碼示例。如果您正苦於以下問題:Java WebBackForwardList類的具體用法?Java WebBackForwardList怎麽用?Java WebBackForwardList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WebBackForwardList類屬於android.webkit包,在下文中一共展示了WebBackForwardList類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPageFinished
import android.webkit.WebBackForwardList; //導入依賴的package包/類
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);
}
}
}
示例2: _backEvent
import android.webkit.WebBackForwardList; //導入依賴的package包/類
private void _backEvent() {
if (this.mWebView != null && this.mWebView.canGoBack()) {
this.mWebView.stopLoading();
LogInfo.log("+->", "mWebView-->>back" + this.mWebView.getUrl());
WebBackForwardList list = this.mWebView.copyBackForwardList();
if (list.getCurrentIndex() <= 0) {
this.pullDownUrlText.setText(String.format(getString(R.string.supplied_by), new Object[]{getUrlTitle(list.getItemAtIndex(0).getUrl())}));
} else {
this.pullDownUrlText.setText(String.format(getString(R.string.supplied_by), new Object[]{getUrlTitle(list.getItemAtIndex(list.getCurrentIndex() - 1).getUrl())}));
this.titleView.setText(list.getItemAtIndex(list.getCurrentIndex() - 1).getTitle());
}
this.mWebView.goBack();
if (!this.close.isShown()) {
this.close.setVisibility(0);
}
} else if ("floatBallActive".equals(this.web_flag)) {
finish();
} else {
finish();
}
}
示例3: backAction
import android.webkit.WebBackForwardList; //導入依賴的package包/類
@Override
public void backAction() {
String curUrl = webView.getUrl();
boolean isExit = true;
if (!TextUtils.isEmpty(curUrl)) {
if (webView.canGoBack()) {
WebBackForwardList backList = webView.copyBackForwardList();
if (backList != null && backList.getCurrentIndex() == 1) {
isExit = false;
loadLocalHtml(articleBean.getBody());
}
}
}
if (isExit) {
mActivity.finish();
}
}
示例4: onKeyDown
import android.webkit.WebBackForwardList; //導入依賴的package包/類
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) {
WebBackForwardList webBFL = webView.copyBackForwardList();
int i = webBFL.getCurrentIndex();
do {
i--;
}
while (i >= 0 && webView.getOriginalUrl()
.equals(webBFL.getItemAtIndex(i).getOriginalUrl()));
if (webView.canGoBackOrForward(i - webBFL.getCurrentIndex())) {
webView.goBackOrForward(i - webBFL.getCurrentIndex());
} else {
super.onBackPressed();
}
return true;
}
return false;
}
示例5: copyBackForwardList
import android.webkit.WebBackForwardList; //導入依賴的package包/類
public WebBackForwardList copyBackForwardList(){
//mWebView.saveState()
WebBackForwardList wbfl = mWebView.copyBackForwardList();
//mWebView.s
return wbfl;
}
示例6: onBackPressedSupport
import android.webkit.WebBackForwardList; //導入依賴的package包/類
@Override
public void onBackPressedSupport() {
if (nswvDetailContent.canGoBack()) {
//獲取webView的瀏覽記錄
WebBackForwardList mWebBackForwardList = nswvDetailContent.copyBackForwardList();
//這裏的判斷是為了讓頁麵在有上一個頁麵的情況下,跳轉到上一個html頁麵,而不是退出當前activity
if (mWebBackForwardList.getCurrentIndex() > 0) {
nswvDetailContent.goBack();
return;
}
}
super.onBackPressedSupport();
}
示例7: onClick
import android.webkit.WebBackForwardList; //導入依賴的package包/類
public void onClick(View v) {
int id = v.getId();
if (id == R.id.close_iv) {
finish();
} else if (id == R.id.back_iv) {
if (this.mWebView.canGoBack()) {
LogInfo.log("+->", "mWebView-->>back" + this.mWebView.getUrl());
WebBackForwardList list = this.mWebView.copyBackForwardList();
if (list.getCurrentIndex() <= 0) {
this.pullDownUrlText.setText(String.format(getString(R.string.supplied_by), new Object[]{getUrlTitle(list.getItemAtIndex(0).getUrl())}));
this.titleView.setText(list.getItemAtIndex(0).getTitle());
} else {
this.pullDownUrlText.setText(String.format(getString(R.string.supplied_by), new Object[]{getUrlTitle(list.getItemAtIndex(list.getCurrentIndex() - 1).getUrl())}));
this.titleView.setText(list.getItemAtIndex(list.getCurrentIndex() - 1).getTitle());
}
this.mWebView.goBack();
if (!this.close.isShown()) {
this.close.setVisibility(0);
}
} else if ("floatBallActive".equals(this.web_flag)) {
finish();
} else {
finish();
}
}
UIsUtils.hideSoftkeyboard(this);
}
示例8: printBackForwardList
import android.webkit.WebBackForwardList; //導入依賴的package包/類
public void printBackForwardList() {
WebBackForwardList currentList = this.copyBackForwardList();
int currentSize = currentList.getSize();
for(int i = 0; i < currentSize; ++i)
{
WebHistoryItem item = currentList.getItemAtIndex(i);
String url = item.getUrl();
LOG.d(TAG, "The URL at index: " + Integer.toString(i) + " is " + url );
}
}
示例9: startOfHistory
import android.webkit.WebBackForwardList; //導入依賴的package包/類
public boolean startOfHistory()
{
WebBackForwardList currentList = this.copyBackForwardList();
WebHistoryItem item = currentList.getItemAtIndex(0);
if( item!=null){ // Null-fence in case they haven't called loadUrl yet (CB-2458)
String url = item.getUrl();
String currentUrl = this.getUrl();
LOG.d(TAG, "The current URL is: " + currentUrl);
LOG.d(TAG, "The URL at item 0 is: " + url);
return currentUrl.equals(url);
}
return false;
}
示例10: restoreState
import android.webkit.WebBackForwardList; //導入依賴的package包/類
public WebBackForwardList restoreState(Bundle savedInstanceState)
{
WebBackForwardList myList = super.restoreState(savedInstanceState);
Log.d(TAG, "WebView restoration crew now restoring!");
//Initialize the plugin manager once more
this.pluginManager.init();
return myList;
}
示例11: back
import android.webkit.WebBackForwardList; //導入依賴的package包/類
private void back() {
if (webView.canGoBack()) {
WebBackForwardList mWebBackForwardList = webView.copyBackForwardList();
String historyUrl = mWebBackForwardList.getItemAtIndex(mWebBackForwardList.getCurrentIndex()-1).getUrl();
webView.goBack();
SearchText.setText(historyUrl);
}
}
示例12: forward
import android.webkit.WebBackForwardList; //導入依賴的package包/類
private void forward() {
if (webView.canGoForward()) {
WebBackForwardList mWebBackForwardList = webView.copyBackForwardList();
String historyUrl = mWebBackForwardList.getItemAtIndex(mWebBackForwardList.getCurrentIndex()+1).getUrl();
webView.goForward();
SearchText.setText(webView.getUrl());
}
}
示例13: restoreWebViewState
import android.webkit.WebBackForwardList; //導入依賴的package包/類
@Override
public void restoreWebViewState(Session session) {
final Bundle stateData = session.getWebViewState();
final WebBackForwardList backForwardList = stateData != null
? super.restoreState(stateData)
: null;
final String desiredURL = session.getUrl().getValue();
client.restoreState(stateData);
client.notifyCurrentURL(desiredURL);
// Pages are only added to the back/forward list when loading finishes. If a new page is
// loading when the Activity is paused/killed, then that page won't be in the list,
// and needs to be restored separately to the history list. We detect this by checking
// whether the last fully loaded page (getCurrentItem()) matches the last page that the
// WebView was actively loading (which was retrieved during onSaveInstanceState():
// WebView.getUrl() always returns the currently loading or loaded page).
// If the app is paused/killed before the initial page finished loading, then the entire
// list will be null - so we need to additionally check whether the list even exists.
if (backForwardList != null &&
backForwardList.getCurrentItem().getUrl().equals(desiredURL)) {
// restoreState doesn't actually load the current page, it just restores navigation history,
// so we also need to explicitly reload in this case:
reload();
} else {
loadUrl(desiredURL);
}
}
示例14: goBack
import android.webkit.WebBackForwardList; //導入依賴的package包/類
@Override
public void goBack() {
WebBackForwardList list = mWebView.copyBackForwardList();
int curIndex = list.getCurrentIndex();
WebHistoryItem curItem = list.getCurrentItem();
WebHistoryItem prevItem = list.getItemAtIndex(curIndex - 1);
int steps = 0;
if (prevItem != null) {
steps--;
if (prevItem.getUrl().equals(JoyWeb.getCookie())) {
prevItem = list.getItemAtIndex(curIndex - 2);
if (prevItem != null) {
steps--;
if (UriUtils.isEquals(prevItem.getUrl(), curItem.getUrl())) {
prevItem = list.getItemAtIndex(curIndex - 3);
if (prevItem != null) {
steps--;
goBackOrForward(steps);
} else {
mBaseView.finish();
}
return;
}
goBackOrForward(steps);
} else {
mBaseView.finish();
}
return;
}
if (goBackOrForward(steps)) {
return;
}
}
mBaseView.finish();
}
示例15: goForward
import android.webkit.WebBackForwardList; //導入依賴的package包/類
@Override
public void goForward() {
WebBackForwardList list = mWebView.copyBackForwardList();
int curIndex = list.getCurrentIndex();
WebHistoryItem curItem = list.getCurrentItem();
WebHistoryItem nextItem = list.getItemAtIndex(curIndex + 1);
int steps = 0;
if (nextItem != null) {
steps++;
if (nextItem.getUrl().equals(JoyWeb.getCookie())) {
nextItem = list.getItemAtIndex(curIndex + 2);
if (nextItem != null) {
steps++;
if (UriUtils.isEquals(nextItem.getUrl(), curItem.getUrl())) {
nextItem = list.getItemAtIndex(curIndex + 3);
if (nextItem != null) {
steps++;
goBackOrForward(steps);
} else {
mBaseView.showToast(R.string.toast_no_next_page);
}
return;
}
if (goBackOrForward(steps)) {
return;
}
}
}
if (goBackOrForward(steps)) {
return;
}
}
mBaseView.showToast(R.string.toast_no_next_page);
}