Code example for WebView

Methods: capturePicturegetScale, getScrollX, getScrollY, getWidth

0
        // point we need to listen for new pictures since the WebView is still 
        // active. 
        final WebView w = t.getTopWindow();
        w.setPictureListener(t);
        // Capture the picture here instead of populatePickerData since it can 
        // be called when saving the state of a tab. 
        t.mPickerData.mPicture = w.capturePicture();
    } 
 
    // Create the PickerData and populate it using the saved state of the tab. 
    private void populatePickerDataFromSavedState(Tab t) {
        if (t.mSavedState == null) {
            return; 
        } 
 
        final PickerData data = new PickerData();
        final Bundle state = t.mSavedState;
        data.mUrl = state.getString(CURRURL);
        data.mTitle = state.getString(CURRTITLE);
        data.mWidth = state.getInt(CURRWIDTH, 0);
        // XXX: These keys are from WebView.savePicture so if they change, this 
        // will break. 
        data.mScale = state.getFloat("scale", 1.0f);
        data.mScrollX = state.getInt("scrollX", 0);
        data.mScrollY = state.getInt("scrollY", 0);
 
        if (state.containsKey(CURRPICTURE)) {
            final File f = new File(t.mSavedState.getString(CURRPICTURE));
            try { 
                final FileInputStream in = new FileInputStream(f);
                data.mPicture = Picture.createFromStream(in);
                in.close();
            } catch (Exception ex) {
                // Ignore any problems with inflating the picture. We just 
                // won't draw anything. 
            } 
        } 
 
        // Set the tab's picker data. 
        t.mPickerData = data;
    } 
 
    // Populate the picker data using the given history item and the current 
    // top WebView. 
    private void populatePickerData(Tab t, WebHistoryItem item) {
        final PickerData data = new PickerData();
        if (item != null) {
            data.mUrl = item.getUrl();
            data.mTitle = item.getTitle();
            if (data.mTitle == null) {
                data.mTitle = data.mUrl;
            } 
        } 
        // We want to display the top window in the tab picker but use the url 
        // and title of the main window. 
        final WebView w = t.getTopWindow();
        data.mWidth = w.getWidth();
        data.mScale = w.getScale();
        data.mScrollX = w.getScrollX();
        data.mScrollY = w.getScrollY();
        t.mPickerData = data;
    } 
     
    /**