android.webkit.WebBackForwardList Java Examples

The following examples show how to use android.webkit.WebBackForwardList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseWebActivity.java    From Hentoid with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: AgentWebView.java    From AgentWeb with Apache License 2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #3
Source File: ClientWebView.java    From habpanelviewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean canGoBackOrForward(int 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);

        if (!item.getOriginalUrl().startsWith("data:")) {
            count += increment;

            if (count == steps) {
                return true;
            }
        }
    }

    return false;
}
 
Example #4
Source File: ClientWebView.java    From habpanelviewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void goBackOrForward(int 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);

        if (!item.getOriginalUrl().startsWith("data:")) {
            count += increment;

            if (count == steps) {
                super.goBackOrForward(intCount);
                return;
            }
        }
    }
}
 
Example #5
Source File: InviteWebviewimpl.java    From letv with Apache License 2.0 6 votes vote down vote up
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();
    }
}
 
Example #6
Source File: ZhihuArticleFragment.java    From DoingDaily with Apache License 2.0 6 votes vote down vote up
@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();
    }
}
 
Example #7
Source File: CordovaWebView.java    From bluemix-parking-meter with MIT License 5 votes vote down vote up
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;
}
 
Example #8
Source File: BitWebViewFragment.java    From tysq-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onConsumeBackEvent(FragmentManager fragmentManager) {
    WebBackForwardList webBackForwardList = this.mWebView.copyBackForwardList();

    //如果有回退历史,而且可回退,就消费该事件
    if (webBackForwardList.getSize() > 0 && this.mWebView.canGoBack()) {
        this.mWebView.goBack();
        return true;
    }

    return super.onConsumeBackEvent(fragmentManager);
}
 
Example #9
Source File: CordovaWebView.java    From bluemix-parking-meter with MIT License 5 votes vote down vote up
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;
}
 
Example #10
Source File: CordovaWebView.java    From reader with MIT License 5 votes vote down vote up
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 );
    }
}
 
Example #11
Source File: CordovaWebView.java    From reader with MIT License 5 votes vote down vote up
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;
}
 
Example #12
Source File: CordovaWebView.java    From reader with MIT License 5 votes vote down vote up
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;
}
 
Example #13
Source File: CordovaWebView.java    From reader with MIT License 5 votes vote down vote up
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 );
    }
}
 
Example #14
Source File: CordovaWebView.java    From reader with MIT License 5 votes vote down vote up
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;
}
 
Example #15
Source File: CordovaWebView.java    From reader with MIT License 5 votes vote down vote up
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;
}
 
Example #16
Source File: CordovaWebView.java    From phonegapbootcampsite with MIT License 5 votes vote down vote up
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 );
    }
}
 
Example #17
Source File: CordovaWebView.java    From phonegapbootcampsite with MIT License 5 votes vote down vote up
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;
}
 
Example #18
Source File: CordovaWebView.java    From phonegapbootcampsite with MIT License 5 votes vote down vote up
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;
}
 
Example #19
Source File: CordovaWebView.java    From CordovaYoutubeVideoPlayer with MIT License 5 votes vote down vote up
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 );
    }
}
 
Example #20
Source File: CordovaWebView.java    From CordovaYoutubeVideoPlayer with MIT License 5 votes vote down vote up
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;
}
 
Example #21
Source File: CordovaWebView.java    From CordovaYoutubeVideoPlayer with MIT License 5 votes vote down vote up
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;
}
 
Example #22
Source File: CordovaWebView.java    From wildfly-samples with MIT License 5 votes vote down vote up
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 );
    }
}
 
Example #23
Source File: CordovaWebView.java    From wildfly-samples with MIT License 5 votes vote down vote up
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;
}
 
Example #24
Source File: CordovaWebView.java    From wildfly-samples with MIT License 5 votes vote down vote up
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;
}
 
Example #25
Source File: CordovaWebView.java    From phonegap-plugin-loading-spinner with Apache License 2.0 5 votes vote down vote up
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 );
    }
}
 
Example #26
Source File: CordovaWebView.java    From phonegap-plugin-loading-spinner with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #27
Source File: CordovaWebView.java    From phonegap-plugin-loading-spinner with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #28
Source File: FirstActivity1.java    From YCWebView with Apache License 2.0 5 votes vote down vote up
private void getWebTitle(WebView view){
    WebBackForwardList forwardList = view.copyBackForwardList();
    WebHistoryItem item = forwardList.getCurrentItem();
    if (item != null) {
        tvTitle.setText(item.getTitle());
       // X5LogUtils.i("-------onReceivedTitle----getWebTitle---"+item.getTitle());
    }
}
 
Example #29
Source File: BitHtmlWebViewFragment.java    From tysq-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onConsumeBackEvent(FragmentManager fragmentManager) {
    WebBackForwardList webBackForwardList = this.mWebView.copyBackForwardList();

    //如果有回退历史,而且可回退,就消费该事件
    if (webBackForwardList.getSize() > 0 && this.mWebView.canGoBack()) {
        this.mWebView.goBack();
        return true;
    }

    return super.onConsumeBackEvent(fragmentManager);
}
 
Example #30
Source File: DappBrowserFragment.java    From alpha-wallet-android with MIT License 5 votes vote down vote up
/**
 * Check if this is the last web item and the last fragment item.
 */
private void checkBackClickArrowVisibility()
{
    //will this be last item?
    WebBackForwardList sessionHistory = web3.copyBackForwardList();
    int nextIndex = sessionHistory.getCurrentIndex() - 1;
    if (backFragmentStack.peekLast() == null && nextIndex <= 0) back.setAlpha(0.3f);
    else back.setAlpha(1.0f);

    next.setAlpha(1.0f); //if we clicked back then we would have a next available
}