Android: Change QtWindow Runnables to lambdas

Pick-to: 6.7
Change-Id: I19a3e0a0a035a49965d7643db3ebdb72de95a3a9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Tinja Paavoseppä 2024-02-07 11:12:11 +02:00
parent 1f2570976e
commit 46c2d587b0

View File

@ -88,90 +88,72 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
final int imageDepth, final boolean isOpaque, final int imageDepth, final boolean isOpaque,
final int surfaceContainerType) // TODO constant for type final int surfaceContainerType) // TODO constant for type
{ {
QtNative.runAction(new Runnable() { QtNative.runAction(()-> {
@Override if (m_surfaceContainer != null)
public void run() { removeView(m_surfaceContainer);
if (m_surfaceContainer != null)
removeView(m_surfaceContainer);
setLayoutParams(new QtLayout.LayoutParams(w, h, x, y)); setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
if (surfaceContainerType == 0) { if (surfaceContainerType == 0) {
m_surfaceContainer = new QtSurface(getContext(), QtWindow.this, m_surfaceContainer = new QtSurface(getContext(), QtWindow.this,
onTop, imageDepth); onTop, imageDepth);
} else { } else {
m_surfaceContainer = new QtTextureView(getContext(), QtWindow.this, isOpaque); m_surfaceContainer = new QtTextureView(getContext(), QtWindow.this, isOpaque);
}
m_surfaceContainer.setLayoutParams(new QtLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
// The surface container of this window will be added as the first of the stack.
// All other views are stacked based on the order they are created.
addView(m_surfaceContainer, 0);
} }
m_surfaceContainer.setLayoutParams(new QtLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
// The surface container of this window will be added as the first of the stack.
// All other views are stacked based on the order they are created.
addView(m_surfaceContainer, 0);
}); });
} }
public void destroySurface() public void destroySurface()
{ {
QtNative.runAction(new Runnable() { QtNative.runAction(()-> {
@Override if (m_surfaceContainer != null) {
public void run() { removeView(m_surfaceContainer);
if (m_surfaceContainer != null) { m_surfaceContainer = null;
removeView(m_surfaceContainer);
m_surfaceContainer = null;
}
} }
}); });
} }
public void setGeometry(final int x, final int y, final int w, final int h) public void setGeometry(final int x, final int y, final int w, final int h)
{ {
QtNative.runAction(new Runnable() { QtNative.runAction(()-> {
@Override if (getContext() instanceof QtActivityBase)
public void run() { setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
if (getContext() instanceof QtActivityBase)
setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
}
}); });
} }
public void addChildWindow(QtWindow window) public void addChildWindow(QtWindow window)
{ {
QtNative.runAction(new Runnable() { QtNative.runAction(()-> {
@Override m_childWindows.put(window.getId(), window);
public void run() { addView(window, getChildCount());
m_childWindows.put(window.getId(), window);
addView(window, getChildCount());
}
}); });
} }
public void removeChildWindow(int id) public void removeChildWindow(int id)
{ {
QtNative.runAction(new Runnable() { QtNative.runAction(()-> {
@Override if (m_childWindows.containsKey(id))
public void run() { removeView(m_childWindows.remove(id));
if (m_childWindows.containsKey(id))
removeView(m_childWindows.remove(id));
}
}); });
} }
public void setNativeView(final View view, public void setNativeView(final View view,
final int x, final int y, final int w, final int h) final int x, final int y, final int w, final int h)
{ {
QtNative.runAction(new Runnable() { QtNative.runAction(()-> {
@Override if (m_nativeView != null)
public void run() { removeView(m_nativeView);
if (m_nativeView != null)
removeView(m_nativeView);
m_nativeView = view; m_nativeView = view;
QtWindow.this.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y)); QtWindow.this.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
m_nativeView.setLayoutParams(new QtLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, m_nativeView.setLayoutParams(new QtLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT)); ViewGroup.LayoutParams.MATCH_PARENT));
addView(m_nativeView); addView(m_nativeView);
}
}); });
} }
@ -187,26 +169,20 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
} }
public void bringChildToBack(int id) { public void bringChildToBack(int id) {
QtNative.runAction(new Runnable() { QtNative.runAction(()-> {
@Override View view = m_childWindows.get(id);
public void run() { if (view != null) {
View view = m_childWindows.get(id); moveChild(view, 0);
if (view != null) {
moveChild(view, 0);
}
} }
}); });
} }
public void removeNativeView() public void removeNativeView()
{ {
QtNative.runAction(new Runnable() { QtNative.runAction(()-> {
@Override if (m_nativeView != null) {
public void run() { removeView(m_nativeView);
if (m_nativeView != null) { m_nativeView = null;
removeView(m_nativeView);
m_nativeView = null;
}
} }
}); });
} }