You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
unify View construction and measurement
No longer allow constructing Views without Context. Lets have only one onMeasure() method to unify behaviour
This commit is contained in:
@@ -814,14 +814,11 @@ public class View extends Object {
|
||||
private int oldWidth;
|
||||
private int oldHeight;
|
||||
private boolean haveCustomMeasure;
|
||||
protected boolean haveComplexMeasure = false;
|
||||
|
||||
private int visibility = View.VISIBLE;
|
||||
private float alpha = 1.0f;
|
||||
|
||||
public View() {
|
||||
this(Context.this_application);
|
||||
} // FIXME
|
||||
|
||||
public View(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
@@ -970,7 +967,7 @@ public class View extends Object {
|
||||
if (haveCustomMeasure) // calling native_measure here would create infinite loop
|
||||
setMeasuredDimension(getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec), getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec));
|
||||
else
|
||||
native_measure(widget, widthMeasureSpec, heightMeasureSpec, false);
|
||||
native_measure(widget, widthMeasureSpec, heightMeasureSpec, haveComplexMeasure);
|
||||
}
|
||||
|
||||
public void setPressed(boolean pressed) {
|
||||
|
||||
@@ -12,38 +12,23 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
||||
public int id;
|
||||
public ArrayList<View> children;
|
||||
|
||||
public ViewGroup() {
|
||||
children = new ArrayList<View>();
|
||||
}
|
||||
|
||||
public ViewGroup(Context context) {
|
||||
super(context);
|
||||
|
||||
children = new ArrayList<View>();
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ViewGroup(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
children = new ArrayList<View>();
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public ViewGroup(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs);
|
||||
|
||||
children = new ArrayList<View>();
|
||||
this(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
public ViewGroup(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
children = new ArrayList<View>();
|
||||
}
|
||||
|
||||
public ViewGroup(int _id) { // FIXME
|
||||
children = new ArrayList<View>();
|
||||
|
||||
id = _id;
|
||||
haveComplexMeasure = true;
|
||||
}
|
||||
|
||||
public void addView(View child) {
|
||||
@@ -128,11 +113,6 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
||||
removeView(child);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
native_measure(widget, widthMeasureSpec, heightMeasureSpec, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected native long native_constructor(Context context, AttributeSet attrs);
|
||||
protected native void native_addView(long widget, long child, int index, LayoutParams params);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package android.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.SurfaceHolder;
|
||||
|
||||
public class Window {
|
||||
@@ -49,7 +50,7 @@ public class Window {
|
||||
public View getDecorView() {
|
||||
if (contentView != null)
|
||||
return contentView;
|
||||
return new View(); // FIXME: this can probably backfire
|
||||
return new View(Context.this_application); // FIXME: this can probably backfire
|
||||
}
|
||||
|
||||
private native void set_widget_as_root(long native_window, long widget);
|
||||
|
||||
Reference in New Issue
Block a user