bug 944104 - support creating a GeckoView programmatically r=mfinkle

This commit is contained in:
Brad Lassey 2013-11-27 17:58:41 -05:00
parent 3333d49ee9
commit d7c4523357
2 changed files with 24 additions and 0 deletions

View File

@ -37,13 +37,21 @@ public class GeckoView extends LayerView
private ChromeDelegate mChromeDelegate;
private ContentDelegate mContentDelegate;
public GeckoView(Context context) {
super(context);
init(context, null, true);
}
public GeckoView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GeckoView);
String url = a.getString(R.styleable.GeckoView_url);
boolean doInit = a.getBoolean(R.styleable.GeckoView_doinit, true);
a.recycle();
init(context, url, doInit);
}
private void init(Context context, String url, boolean doInit) {
// TODO: Fennec currently takes care of its own initialization, so this
// flag is a hack used in Fennec to prevent GeckoView initialization.
// This should go away once Fennec also uses GeckoView for

View File

@ -119,6 +119,22 @@ public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener
Tabs.registerOnTabsChangedListener(this);
}
public LayerView(Context context) {
super(context);
mGLController = GLController.getInstance(this);
mPaintState = PAINT_START;
mBackgroundColor = Color.WHITE;
mTouchInterceptors = new ArrayList<TouchEventInterceptor>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
mOverscroll = new OverscrollEdgeEffect(this);
} else {
mOverscroll = null;
}
Tabs.registerOnTabsChangedListener(this);
}
public void initializeView(EventDispatcher eventDispatcher) {
mLayerClient = new GeckoLayerClient(getContext(), this, eventDispatcher);
if (mOverscroll != null) {