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
View: add basic implemntation of dispatchTouchEvent
Some Views block all events going to their descendants, and then synthesize new events themselves. Gtk doesn't allow event synthesization, which makes this quite annoying to deal with. This initial implementation definiely has some problems, for example it seems to cause infinite loops in some cases, however it surprisingly works well enough.
This commit is contained in:
@@ -61,6 +61,10 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
||||
addView(child, params);
|
||||
}
|
||||
|
||||
public void addView(View child, int index, LayoutParams params) {
|
||||
addViewInternal(child, index, params);
|
||||
}
|
||||
|
||||
protected void addViewInternal(View child, int index, LayoutParams params) {
|
||||
if (child.parent == this)
|
||||
return;
|
||||
@@ -81,10 +85,13 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void addView(View child, int index, LayoutParams params) {
|
||||
addViewInternal(child, index, params);
|
||||
/* We never call this ourselves */
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
return native_dispatchTouchEvent(widget, event, event.getX(), event.getY());
|
||||
}
|
||||
|
||||
|
||||
protected boolean addViewInLayout(View child, int index, LayoutParams params) {
|
||||
addViewInternal(child, index, params);
|
||||
return true;
|
||||
@@ -169,6 +176,16 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchVisibilityChanged(View changedView, int visibility) {
|
||||
if (children == null) // happens if this gets called during super constructor
|
||||
return;
|
||||
|
||||
for (View child: children) {
|
||||
child.dispatchVisibilityChanged(changedView, visibility);
|
||||
}
|
||||
}
|
||||
|
||||
protected native void native_addView(long widget, long child, int index, LayoutParams params);
|
||||
protected native void native_removeView(long widget, long child);
|
||||
@Override
|
||||
@@ -636,4 +653,6 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
||||
}
|
||||
|
||||
public void requestChildFocus(View child, View focused) {}
|
||||
|
||||
public native boolean native_dispatchTouchEvent(long widget, MotionEvent event, double x, double y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user