diff options
author | Tinja Paavoseppä <tinja.paavoseppa@qt.io> | 2024-02-07 11:12:11 +0200 |
---|---|---|
committer | Tinja Paavoseppä <tinja.paavoseppa@qt.io> | 2024-02-12 08:50:59 +0200 |
commit | 46c2d587b07ca99d36a28402924d7a7cf9c1b3e0 (patch) | |
tree | 628d86a2d42ce3bc6a0d4484c9369e9871172a25 /src/android/jar/src/org/qtproject/qt | |
parent | 1f2570976e3b337a7f9eefea0c6937e943b7887a (diff) |
Android: Change QtWindow Runnables to lambdas
Pick-to: 6.7
Change-Id: I19a3e0a0a035a49965d7643db3ebdb72de95a3a9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/android/jar/src/org/qtproject/qt')
-rw-r--r-- | src/android/jar/src/org/qtproject/qt/android/QtWindow.java | 116 |
1 files changed, 46 insertions, 70 deletions
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; } }); } |