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:
@@ -17,26 +17,24 @@ public class ImageView extends View {
|
||||
private ScaleType scaleType = ScaleType.FIT_CENTER;
|
||||
|
||||
public ImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
if (attrs != null) {
|
||||
int resource = attrs.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "src", 0);
|
||||
if (resource != 0)
|
||||
setImageResource(resource);
|
||||
}
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public ImageView(Context context) {
|
||||
super(context);
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ImageView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
native_measure(widget, widthMeasureSpec, heightMeasureSpec, true);
|
||||
haveComplexMeasure = true;
|
||||
if (attrs != null) {
|
||||
int resid = attrs.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "src", 0);
|
||||
if (resid != 0 && !getResources().getString(resid).endsWith(".xml")) {
|
||||
bitmap = BitmapFactory.decodeResource(getResources(), resid);
|
||||
native_setPixbuf(bitmap.pixbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,10 +22,6 @@ import android.view.View;
|
||||
public class TextView extends View {
|
||||
public String text;
|
||||
|
||||
public TextView(int _id) { // FIXME
|
||||
id = _id;
|
||||
}
|
||||
|
||||
public TextView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
@@ -50,6 +46,7 @@ public class TextView extends View {
|
||||
}
|
||||
a.recycle();
|
||||
}
|
||||
haveComplexMeasure = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,11 +68,6 @@ public class TextView extends View {
|
||||
setText(getContext().getResources().getText(resId));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
native_measure(widget, widthMeasureSpec, heightMeasureSpec, true);
|
||||
}
|
||||
|
||||
private native final void native_set_markup(int bool);
|
||||
|
||||
public native final void native_setText(String text);
|
||||
|
||||
Reference in New Issue
Block a user