call View.onAttachedToWindow() method

This commit is contained in:
Julian Winkler
2023-10-08 17:51:41 +02:00
parent f4251af2a2
commit 520d153c55
8 changed files with 43 additions and 7 deletions

View File

@@ -2,6 +2,8 @@ package android.os;
public class ConditionVariable {
public ConditionVariable(boolean state) {}
public void open() {}
public void block() {}

View File

@@ -1540,11 +1540,11 @@ public final class MotionEvent extends InputEvent {
pc[0].pressure = pressure;
pc[0].size = size;
ev.mNativePtr = nativeInitialize(ev.mNativePtr,
deviceId, /*InputDevice.SOURCE_UNKNOWN*/ 0, action, 0, edgeFlags, metaState, 0,
0, 0, xPrecision, yPrecision,
downTime * NS_PER_MS, eventTime * NS_PER_MS,
1, pp, pc);
// ev.mNativePtr = nativeInitialize(ev.mNativePtr,
// deviceId, /*InputDevice.SOURCE_UNKNOWN*/ 0, action, 0, edgeFlags, metaState, 0,
// 0, 0, xPrecision, yPrecision,
// downTime * NS_PER_MS, eventTime * NS_PER_MS,
// 1, pp, pc);
return ev;
}
}

View File

@@ -5,4 +5,8 @@ public class VelocityTracker {
public static VelocityTracker obtain() {
return new VelocityTracker();
}
public void addMovement(MotionEvent event) {}
public void recycle() {}
}

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
@@ -799,6 +800,8 @@ public class View extends Object {
private int scrollX = 0;
private int scrollY = 0;
private boolean attachedToWindow = false;
public long widget; // pointer
public static HashMap<Integer, View> view_by_id = new HashMap<Integer, View>();
@@ -1247,7 +1250,7 @@ public class View extends Object {
public void clearAnimation() {}
public ViewPropertyAnimator animate() {
return new ViewPropertyAnimator();
return new ViewPropertyAnimator(this);
}
public float getTranslationX() {return 0.f;}
@@ -1385,7 +1388,7 @@ public class View extends Object {
public void setPaddingRelative(int start, int top, int end, int bottom) {}
public boolean isAttachedToWindow() {return true;}
public boolean isAttachedToWindow() {return attachedToWindow;}
public void requestApplyInsets() {}
@@ -1457,4 +1460,10 @@ public class View extends Object {
}
public void setKeepScreenOn(boolean screenOn) {}
protected void onAttachedToWindow () {
attachedToWindow = true;
}
public void setLayerType(int layerType, Paint paint) {}
}

View File

@@ -75,6 +75,9 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
index = children.size();
children.add(index, child);
native_addView(widget, child.widget, index, params);
if (isAttachedToWindow()) {
child.onAttachedToWindow();
}
requestLayout();
}
@@ -291,6 +294,14 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
for (View child: children) {
child.onAttachedToWindow();
}
}
public static class LayoutParams {
public static final int FILL_PARENT = -1;
public static final int MATCH_PARENT = -1;

View File

@@ -5,6 +5,12 @@ import android.animation.TimeInterpolator;
public class ViewPropertyAnimator {
private View view;
public ViewPropertyAnimator(View view) {
this.view = view;
}
public void cancel() {}
public ViewPropertyAnimator setInterpolator(TimeInterpolator interpolator) {
@@ -18,6 +24,7 @@ public class ViewPropertyAnimator {
}
public ViewPropertyAnimator alpha(float alpha) {
view.setAlpha(alpha);
return this;
}

View File

@@ -43,6 +43,7 @@ public class Window {
public void setContentView(View view) {
if (view != contentView) {
contentView = view;
view.onAttachedToWindow();
set_widget_as_root(native_window, view.widget);
}
}

View File

@@ -183,6 +183,8 @@ public class TextView extends View {
return new MovementMethod();
}
public CharSequence getHint() {return "HINT";}
public static interface OnEditorActionListener {
}