Example usage for android.webkit WebHistoryItem getUrl

List of usage examples for android.webkit WebHistoryItem getUrl

Introduction

In this page you can find the example usage for android.webkit WebHistoryItem getUrl.

Prototype

public abstract String getUrl();

Source Link

Document

Return the url of this history item.

Usage

From source file:com.example.administrator.mywebviewdrawsign.SysWebView.java

public boolean startOfHistory() {
    WebBackForwardList currentList = this.copyBackForwardList();
    WebHistoryItem item = currentList.getItemAtIndex(0);
    String url = item.getUrl();
    String currentUrl = this.getUrl();
    LogUtils.d("The current URL is: " + currentUrl);
    LogUtils.d("The URL at item 0 is:" + url);
    return currentUrl.equals(url);
}

From source file:com.robandjen.comicsapp.FullscreenActivity.java

@Override
public void onBackPressed() {
    ComicsWebView wv = (ComicsWebView) findViewById(R.id.fullscreen_content);
    if (wv.canGoBack()) {

        //I couldn't remove every URL from the list, so stop when I hit
        //about:blank, I'm all the way back then
        WebBackForwardList bdl = wv.copyBackForwardList();
        final int cur = bdl.getCurrentIndex() - 1;
        if (cur >= 0) {
            WebHistoryItem whi = bdl.getItemAtIndex(cur);
            String url = whi.getUrl();
            if (!url.equals("about:blank")) {
                wv.goBack();/*from   w  ww . j av  a 2s  .co m*/
            }
        }

    }

}

From source file:org.apache.cordova.AndroidWebView.java

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);
    }/* w  ww  . j av  a2 s .  c o m*/
}

From source file:org.apache.cordova.AndroidWebView.java

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);
    }/*ww  w  . ja  va  2 s. c o  m*/
    return false;
}

From source file:dev.memento.MementoBrowser.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebview.canGoBack()) {

        // Get the previous URL to update our internal copy 

        WebBackForwardList list = mWebview.copyBackForwardList();
        int curr = list.getCurrentIndex();
        WebHistoryItem item = list.getItemAtIndex(curr - 1);
        Bitmap favicon = item.getFavicon();

        if (favicon == null)
            Log.d(LOG_TAG, "No favicon in WebHistoryItem - null");
        else/*from ww w  .ja v  a2  s.  c  o m*/
            Log.d(LOG_TAG, "WebHistoryItem favicon W = " + favicon.getWidth());

        mOriginalUrl = item.getUrl();
        Log.d(LOG_TAG, "GO BACK TO " + mOriginalUrl);

        mWebview.goBack();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:dev.memento.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    // Back button goes back to previous page or memento
    if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebview.canGoBack()) {

        // Get the previous URL to update our internal copy 

        WebBackForwardList list = mWebview.copyBackForwardList();
        int curr = list.getCurrentIndex();
        WebHistoryItem item = list.getItemAtIndex(curr - 1);
        String url = item.getUrl();

        if (Log.LOG)
            Log.d(LOG_TAG, "GO BACK TO " + url);

        mWebview.goBack();/* w w w  .  j  a  va  2s  . c om*/

        // Reset to today because it might be confusing to set to other dates
        setChosenDate(mToday);

        // Just in case
        mMementoProgressBar.setVisibility(View.GONE);

        if (Log.LOG)
            Log.d(LOG_TAG, "mWebHistory size = " + mWebHistory.size());
        if (mWebHistory.isEmpty()) {
            if (Log.LOG)
                Log.e(LOG_TAG, "Stack maintaining page dates is empty!");
        } else {
            ExWebHistoryItem item2 = mWebHistory.pop(); // Remove current
            if (Log.LOG)
                Log.d(LOG_TAG, "!! Removed item " + item2 + " from stack");

            if (!mWebHistory.isEmpty()) {
                item2 = mWebHistory.peek(); // Previous
                if (Log.LOG)
                    Log.d(LOG_TAG, "!! Top item is " + item2);
            }

            mCurrentMemento = item2.getMemento();
            if (Log.LOG)
                Log.d(LOG_TAG, "mCurrentMemento = " + mCurrentMemento);
            if (mCurrentMemento == null)
                mDateDisplayed = mToday;
            else
                mDateDisplayed = mCurrentMemento.getDateTime();

            if (Log.LOG)
                Log.d(LOG_TAG, "!! Back to date " + mDateDisplayed);
            refreshDisplayedDate();

            // Indicate the user pressed the back button
            mUserPressedBack = true;

            // Should be able to press if it's not today
            mNowButton.setEnabled(mToday.compareDateTo(mDateDisplayed) != 0);

            //if (mCurrentMemento != null && !mCurrentMemento.getUrl().equals(url) && 
            //      !url.equals(mOriginalUrl)) {
            if (!mOriginalUrl.equals(item2.getOriginalUrl())) {
                mOriginalUrl = item2.getOriginalUrl();
                if (Log.LOG)
                    Log.d(LOG_TAG, "** Clearing list of old mementos");
                if (Log.LOG)
                    Log.d(LOG_TAG, "mOriginalUrl = " + mOriginalUrl);
                mMementos.clear();
            }
        }

        return true;
    }
    return super.onKeyDown(keyCode, event);
}