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: replace custom isAttachedToWindow tracking with GTK signals
This commit is contained in:
@@ -841,8 +841,6 @@ public class View implements Drawable.Callback {
|
||||
private int scrollX = 0;
|
||||
private int scrollY = 0;
|
||||
|
||||
private boolean attachedToWindow = false;
|
||||
|
||||
public long widget; // pointer
|
||||
|
||||
private int oldWidthMeasureSpec = -1;
|
||||
@@ -1836,7 +1834,10 @@ public class View implements Drawable.Callback {
|
||||
|
||||
public void setPaddingRelative(int start, int top, int end, int bottom) {}
|
||||
|
||||
public boolean isAttachedToWindow() {return attachedToWindow;}
|
||||
private native boolean nativeIsAttachedToWindow(long widget);
|
||||
public boolean isAttachedToWindow() {
|
||||
return nativeIsAttachedToWindow(widget);
|
||||
}
|
||||
|
||||
public void requestApplyInsets() {}
|
||||
|
||||
@@ -1910,34 +1911,13 @@ public class View implements Drawable.Callback {
|
||||
private boolean keepScreenOn = false;
|
||||
private static native void native_keep_screen_on(long widget, boolean keepScreenOn);
|
||||
public void setKeepScreenOn(boolean screenOn) {
|
||||
if (attachedToWindow && keepScreenOn != screenOn)
|
||||
if (isAttachedToWindow() && keepScreenOn != screenOn)
|
||||
native_keep_screen_on(widget, screenOn);
|
||||
keepScreenOn = screenOn;
|
||||
}
|
||||
|
||||
protected void onAttachedToWindow () {
|
||||
attachedToWindow = true;
|
||||
if (onAttachStateChangeListener != null) {
|
||||
onAttachStateChangeListener.onViewAttachedToWindow(this);
|
||||
}
|
||||
if (keepScreenOn)
|
||||
native_keep_screen_on(widget, true);
|
||||
}
|
||||
protected void onDetachedFromWindow() {
|
||||
if (onAttachStateChangeListener != null) {
|
||||
onAttachStateChangeListener.onViewDetachedFromWindow(this);
|
||||
}
|
||||
if (keepScreenOn)
|
||||
native_keep_screen_on(widget, false);
|
||||
}
|
||||
|
||||
void detachFromWindowInternal() {
|
||||
onDetachedFromWindow();
|
||||
attachedToWindow = false;
|
||||
}
|
||||
public void attachToWindowInternal() {
|
||||
onAttachedToWindow();
|
||||
}
|
||||
protected void onAttachedToWindow() {}
|
||||
protected void onDetachedFromWindow() {}
|
||||
|
||||
public void setLayerType(int layerType, Paint paint) {}
|
||||
|
||||
|
||||
@@ -77,8 +77,6 @@ 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();
|
||||
if (onHierarchyChangeListener != null)
|
||||
onHierarchyChangeListener.onChildViewAdded(this, child);
|
||||
|
||||
@@ -111,8 +109,6 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
||||
child.parent = null;
|
||||
children.remove(child);
|
||||
native_removeView(widget, child.widget);
|
||||
if (isAttachedToWindow())
|
||||
child.detachFromWindowInternal();
|
||||
if (onHierarchyChangeListener != null) {
|
||||
onHierarchyChangeListener.onChildViewRemoved(this, child);
|
||||
}
|
||||
@@ -136,8 +132,6 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
||||
child.parent = null;
|
||||
it.remove();
|
||||
native_removeView(widget, child.widget);
|
||||
if (isAttachedToWindow())
|
||||
child.detachFromWindowInternal();
|
||||
if (onHierarchyChangeListener != null) {
|
||||
onHierarchyChangeListener.onChildViewRemoved(this, child);
|
||||
}
|
||||
@@ -169,8 +163,6 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
||||
return;
|
||||
child.parent = null;
|
||||
native_removeView(widget, child.widget);
|
||||
if (isAttachedToWindow())
|
||||
child.detachFromWindowInternal();
|
||||
if (onHierarchyChangeListener != null) {
|
||||
onHierarchyChangeListener.onChildViewRemoved(this, child);
|
||||
}
|
||||
@@ -363,22 +355,6 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void detachFromWindowInternal() {
|
||||
super.detachFromWindowInternal();
|
||||
for (View child: children) {
|
||||
child.detachFromWindowInternal();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isChildrenDrawingOrderEnabled() { return false; }
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,6 @@ public class Window {
|
||||
this.context = context;
|
||||
decorView = new FrameLayout(context);
|
||||
decorView.setId(android.R.id.content);
|
||||
decorView.onAttachedToWindow();
|
||||
}
|
||||
|
||||
public void addFlags(int flags) {}
|
||||
|
||||
Reference in New Issue
Block a user