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: make sure onDetachedFromWindow() gets called before updating attachedToWindow property
This commit is contained in:
@@ -1876,13 +1876,17 @@ public class View implements Drawable.Callback {
|
|||||||
native_keep_screen_on(widget, true);
|
native_keep_screen_on(widget, true);
|
||||||
}
|
}
|
||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
attachedToWindow = false;
|
|
||||||
if (onAttachStateChangeListener != null) {
|
if (onAttachStateChangeListener != null) {
|
||||||
onAttachStateChangeListener.onViewDetachedFromWindow(this);
|
onAttachStateChangeListener.onViewDetachedFromWindow(this);
|
||||||
}
|
}
|
||||||
if (keepScreenOn)
|
if (keepScreenOn)
|
||||||
native_keep_screen_on(widget, false);
|
native_keep_screen_on(widget, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void detachFromWindowInternal() {
|
||||||
|
onDetachedFromWindow();
|
||||||
|
attachedToWindow = false;
|
||||||
|
}
|
||||||
public void attachToWindowInternal() {
|
public void attachToWindowInternal() {
|
||||||
onAttachedToWindow();
|
onAttachedToWindow();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
|||||||
children.remove(child);
|
children.remove(child);
|
||||||
native_removeView(widget, child.widget);
|
native_removeView(widget, child.widget);
|
||||||
if (isAttachedToWindow())
|
if (isAttachedToWindow())
|
||||||
child.onDetachedFromWindow();
|
child.detachFromWindowInternal();
|
||||||
if (onHierarchyChangeListener != null) {
|
if (onHierarchyChangeListener != null) {
|
||||||
onHierarchyChangeListener.onChildViewRemoved(this, child);
|
onHierarchyChangeListener.onChildViewRemoved(this, child);
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
|||||||
it.remove();
|
it.remove();
|
||||||
native_removeView(widget, child.widget);
|
native_removeView(widget, child.widget);
|
||||||
if (isAttachedToWindow())
|
if (isAttachedToWindow())
|
||||||
child.onDetachedFromWindow();
|
child.detachFromWindowInternal();
|
||||||
if (onHierarchyChangeListener != null) {
|
if (onHierarchyChangeListener != null) {
|
||||||
onHierarchyChangeListener.onChildViewRemoved(this, child);
|
onHierarchyChangeListener.onChildViewRemoved(this, child);
|
||||||
}
|
}
|
||||||
@@ -332,10 +332,10 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDetachedFromWindow() {
|
protected void detachFromWindowInternal() {
|
||||||
super.onDetachedFromWindow();
|
super.detachFromWindowInternal();
|
||||||
for (View child: children) {
|
for (View child: children) {
|
||||||
child.onDetachedFromWindow();
|
child.detachFromWindowInternal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user