gpt4 book ai didi

android.webkit.WebBackForwardList类的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 13:01:05 25 4
gpt4 key购买 nike

本文整理了Java中android.webkit.WebBackForwardList类的一些代码示例,展示了WebBackForwardList类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebBackForwardList类的具体详情如下:
包路径:android.webkit.WebBackForwardList
类名称:WebBackForwardList

WebBackForwardList介绍

暂无

代码示例

代码示例来源: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: 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: cymcsg/UltimateAndroid

/**
   * Get the latest url of webview
   * @param webView
   * @return
   */
  public static String getHistoricalUrl(WebView webView) {
    WebBackForwardList webBackForwardList = getHistoricalList(webView);
    return webBackForwardList.getItemAtIndex(webBackForwardList.getCurrentIndex() - 1).getUrl();

  }
}

代码示例来源: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 shouldReturnHistoryFromSaveState() {
 webView.loadUrl("foo1.bar");
 webView.loadUrl("foo2.bar");
 Bundle outState = new Bundle();
 WebBackForwardList historyList = webView.saveState(outState);
 assertThat(historyList.getSize()).isEqualTo(2);
 assertThat(historyList.getCurrentItem().getUrl()).isEqualTo("foo2.bar");
}

代码示例来源:origin: avluis/Hentoid

@Override
public void onDownloadFabClick(View view) {
  downloadFabPressed = true;
  historyIndex = getWebView().copyBackForwardList().getCurrentIndex();
  String newUrl = getWebView().getUrl().replace("Book/Info", "Read/View");
  final int index = ordinalIndexOf(newUrl);
  if (index > 0) newUrl = newUrl.substring(0, index);
  getWebView().loadUrl(newUrl);
}

代码示例来源:origin: avluis/Hentoid

@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;
}

代码示例来源: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: avluis/Hentoid

@Override
public void onPageFinished(WebView view, String url) {
  super.onPageFinished(view, url);
  BaseWebActivity activity = activityReference.get();
  if (url.contains("//www.tsumino.com/Book/Info/") && activity != null) {
    executeAsyncTask(new HtmlLoader(activity), url);
  } else if (downloadFabPressed && url.contains("//www.tsumino.com/Read/View/")) {
    downloadFabPressed = false;
    int currentIndex = getWebView().copyBackForwardList().getCurrentIndex();
    getWebView().goBackOrForward(historyIndex - currentIndex);
    processDownload();
  }
}

代码示例来源:origin: vbier/habpanelviewer

@Override
public boolean canGoBackOrForward(int steps) {
  Log.d(TAG, "canGoBackOrForward: steps=" + steps);
  int increment = steps < 0 ? -1 : 1;
  WebBackForwardList list = copyBackForwardList();
  int count = 0;
  int startIdx = list.getCurrentIndex();
  for (int i = startIdx + increment; i < list.getSize() && i >= 0; i += increment) {
    WebHistoryItem item = list.getItemAtIndex(i);
    Log.d(TAG, "canGoBackOrForward: item=" + item.getOriginalUrl());
    if (!item.getOriginalUrl().startsWith("data:")) {
      count += increment;
      if (count == steps) {
        Log.d(TAG, "canGoBackOrForward: true");
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: calvinaquino/LNReader-Android

@Override
public boolean canGoBack() {
  WebBackForwardList history = this.copyBackForwardList();
  WebHistoryItem prevData = history.getItemAtIndex(history.getCurrentIndex() - 1);
  if (prevData != null) {
    if (prevData.getUrl().startsWith(PREFIX_PAGEMODEL)) {
      Log.d(TAG, "Previous data is internal page: " + prevData.getUrl());
      return false;
    } else
      Log.d(TAG, "Back to: " + prevData.getUrl());
  }
  return super.canGoBack();
}

代码示例来源: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: robolectric/robolectric

@Test
public void shouldSaveAndRestoreHistoryList() {
 webView.loadUrl("foo1.bar");
 webView.loadUrl("foo2.bar");
 Bundle outState = new Bundle();
 webView.saveState(outState);
 WebView newWebView = new WebView(ApplicationProvider.getApplicationContext());
 WebBackForwardList historyList = newWebView.restoreState(outState);
 assertThat(newWebView.canGoBack()).isTrue();
 assertThat(newWebView.getUrl()).isEqualTo("foo2.bar");
 assertThat(historyList.getSize()).isEqualTo(2);
 assertThat(historyList.getCurrentItem().getUrl()).isEqualTo("foo2.bar");
}

代码示例来源:origin: vbier/habpanelviewer

@Override
public void goBackOrForward(int steps) {
  Log.d(TAG, "goBackOrForward: steps=" + steps);
  int increment = steps < 0 ? -1 : 1;
  WebBackForwardList list = copyBackForwardList();
  int count = 0;
  int intCount = 0;
  int startIdx = list.getCurrentIndex();
  for (int i = startIdx + increment; i < list.getSize() && i >= 0; i += increment) {
    intCount += increment;
    WebHistoryItem item = list.getItemAtIndex(i);
    Log.d(TAG, "goBackOrForward: item=" + item.getOriginalUrl());
    if (!item.getOriginalUrl().startsWith("data:")) {
      count += increment;
      if (count == steps) {
        Log.d(TAG, "goBackOrForward: intCount=" + intCount + ", item=" + item.getOriginalUrl());
        super.goBackOrForward(intCount);
        return;
      }
    }
  }
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com