FakeWebViewpublic class FakeWebView extends android.widget.ImageView This class is used by ImageAdapter to draw a representation of each tab. It
overrides ImageView so it can be used for the new tab image as well. |
Fields Summary |
---|
private TabControl.Tab | mTab | private android.graphics.Picture | mPicture | private boolean | mUsesResource |
Methods Summary |
---|
protected void | onDraw(android.graphics.Canvas canvas)
if (mUsesResource) {
super.onDraw(canvas);
} else {
// Always draw white behind the picture just in case the picture
// draws nothing.
// FIXME: We used to draw white only when the WebView was null but
// sometimes the picture was empty. So now we always draw white. It
// would be nice to know if the picture is empty so we can avoid
// drawing white.
canvas.drawColor(Color.WHITE);
if (mTab != null) {
final WebView w = mTab.getTopWindow();
if (w != null) {
if (mPicture != null) {
canvas.save();
float scale = getWidth() * w.getScale() / w.getWidth();
canvas.scale(scale, scale);
canvas.translate(-w.getScrollX(), -w.getScrollY());
canvas.drawPicture(mPicture);
canvas.restore();
}
}
}
}
| public void | setImageResource(int resId)
mUsesResource = true;
mTab = null;
super.setImageResource(resId);
| public void | setTab(TabControl.Tab t)Set a WebView for this FakeWebView to represent.
mUsesResource = false;
mTab = t;
if (t != null && t.getWebView() != null) {
Listener l = new Listener();
if (t.getSubWebView() != null) {
t.getSubWebView().setPictureListener(l);
} else {
t.getWebView().setPictureListener(l);
}
mPicture = mTab.getTopWindow().capturePicture();
}
|
|