From 46c2d587b07ca99d36a28402924d7a7cf9c1b3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tinja=20Paavosepp=C3=A4?= Date: Wed, 7 Feb 2024 11:12:11 +0200 Subject: Android: Change QtWindow Runnables to lambdas Pick-to: 6.7 Change-Id: I19a3e0a0a035a49965d7643db3ebdb72de95a3a9 Reviewed-by: Assam Boudjelthia --- .../jar/src/org/qtproject/qt/android/QtWindow.java | 116 ++++++++------------- 1 file changed, 46 insertions(+), 70 deletions(-) (limited to 'src/android') diff --git a/src/android/jar/src/org/qtproject/qt/android/QtWindow.java b/src/android/jar/src/org/qtproject/qt/android/QtWindow.java index 1a9a185452..61feade98f 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtWindow.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtWindow.java @@ -88,90 +88,72 @@ class QtWindow extends QtLayout implements QtSurfaceInterface { final int imageDepth, final boolean isOpaque, final int surfaceContainerType) // TODO constant for type { - QtNative.runAction(new Runnable() { - @Override - public void run() { - if (m_surfaceContainer != null) - removeView(m_surfaceContainer); - - setLayoutParams(new QtLayout.LayoutParams(w, h, x, y)); - if (surfaceContainerType == 0) { - m_surfaceContainer = new QtSurface(getContext(), QtWindow.this, - onTop, imageDepth); - } else { - 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); + QtNative.runAction(()-> { + if (m_surfaceContainer != null) + removeView(m_surfaceContainer); + + setLayoutParams(new QtLayout.LayoutParams(w, h, x, y)); + if (surfaceContainerType == 0) { + m_surfaceContainer = new QtSurface(getContext(), QtWindow.this, + onTop, imageDepth); + } else { + 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); }); } public void destroySurface() { - QtNative.runAction(new Runnable() { - @Override - public void run() { - if (m_surfaceContainer != null) { - removeView(m_surfaceContainer); - m_surfaceContainer = null; - } + QtNative.runAction(()-> { + if (m_surfaceContainer != null) { + removeView(m_surfaceContainer); + m_surfaceContainer = null; } }); } public void setGeometry(final int x, final int y, final int w, final int h) { - QtNative.runAction(new Runnable() { - @Override - public void run() { - if (getContext() instanceof QtActivityBase) - setLayoutParams(new QtLayout.LayoutParams(w, h, x, y)); - } + QtNative.runAction(()-> { + if (getContext() instanceof QtActivityBase) + setLayoutParams(new QtLayout.LayoutParams(w, h, x, y)); }); } public void addChildWindow(QtWindow window) { - QtNative.runAction(new Runnable() { - @Override - public void run() { - m_childWindows.put(window.getId(), window); - addView(window, getChildCount()); - } + QtNative.runAction(()-> { + m_childWindows.put(window.getId(), window); + addView(window, getChildCount()); }); } public void removeChildWindow(int id) { - QtNative.runAction(new Runnable() { - @Override - public void run() { - if (m_childWindows.containsKey(id)) - removeView(m_childWindows.remove(id)); - } + QtNative.runAction(()-> { + if (m_childWindows.containsKey(id)) + removeView(m_childWindows.remove(id)); }); } public void setNativeView(final View view, final int x, final int y, final int w, final int h) { - QtNative.runAction(new Runnable() { - @Override - public void run() { - if (m_nativeView != null) - removeView(m_nativeView); - - m_nativeView = view; - QtWindow.this.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y)); - m_nativeView.setLayoutParams(new QtLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT)); - addView(m_nativeView); - } + QtNative.runAction(()-> { + if (m_nativeView != null) + removeView(m_nativeView); + + m_nativeView = view; + QtWindow.this.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y)); + m_nativeView.setLayoutParams(new QtLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); + addView(m_nativeView); }); } @@ -187,26 +169,20 @@ class QtWindow extends QtLayout implements QtSurfaceInterface { } public void bringChildToBack(int id) { - QtNative.runAction(new Runnable() { - @Override - public void run() { - View view = m_childWindows.get(id); - if (view != null) { - moveChild(view, 0); - } + QtNative.runAction(()-> { + View view = m_childWindows.get(id); + if (view != null) { + moveChild(view, 0); } }); } public void removeNativeView() { - QtNative.runAction(new Runnable() { - @Override - public void run() { - if (m_nativeView != null) { - removeView(m_nativeView); - m_nativeView = null; - } + QtNative.runAction(()-> { + if (m_nativeView != null) { + removeView(m_nativeView); + m_nativeView = null; } }); } -- cgit v1.2.3