mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 12:17:57 +03:00
View: make sure onDetachedFromWindow() gets called before updating attachedToWindow property
This commit is contained in:
parent
24f839f556
commit
2374d44b0f
2 changed files with 10 additions and 6 deletions
|
@ -1876,13 +1876,17 @@ public class View implements Drawable.Callback {
|
|||
native_keep_screen_on(widget, true);
|
||||
}
|
||||
protected void onDetachedFromWindow() {
|
||||
attachedToWindow = false;
|
||||
if (onAttachStateChangeListener != null) {
|
||||
onAttachStateChangeListener.onViewDetachedFromWindow(this);
|
||||
}
|
||||
if (keepScreenOn)
|
||||
native_keep_screen_on(widget, false);
|
||||
}
|
||||
|
||||
void detachFromWindowInternal() {
|
||||
onDetachedFromWindow();
|
||||
attachedToWindow = false;
|
||||
}
|
||||
public void attachToWindowInternal() {
|
||||
onAttachedToWindow();
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
|||
children.remove(child);
|
||||
native_removeView(widget, child.widget);
|
||||
if (isAttachedToWindow())
|
||||
child.onDetachedFromWindow();
|
||||
child.detachFromWindowInternal();
|
||||
if (onHierarchyChangeListener != null) {
|
||||
onHierarchyChangeListener.onChildViewRemoved(this, child);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
|||
it.remove();
|
||||
native_removeView(widget, child.widget);
|
||||
if (isAttachedToWindow())
|
||||
child.onDetachedFromWindow();
|
||||
child.detachFromWindowInternal();
|
||||
if (onHierarchyChangeListener != null) {
|
||||
onHierarchyChangeListener.onChildViewRemoved(this, child);
|
||||
}
|
||||
|
@ -332,10 +332,10 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
protected void detachFromWindowInternal() {
|
||||
super.detachFromWindowInternal();
|
||||
for (View child: children) {
|
||||
child.onDetachedFromWindow();
|
||||
child.detachFromWindowInternal();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue