Android: start native app from QtActivityDelegate instead of QtLayout
Starting the native application is not the responsibility of QtLayout instead it makes more sense to be done under QtActivityDelegate so move that logic there and avoid keeping its runnable inside the QtLayout. Task-number: QTBUG-118077 Change-Id: I4869cb5aa741289ed0e9ccaa1cf2ae42c9dd4791 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>bb10
parent
8ddb27a11d
commit
43102fb55f
|
|
@ -16,6 +16,7 @@ import android.os.Build;
|
|||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
|
|
@ -132,20 +133,21 @@ public class QtActivityDelegate
|
|||
if (m_surfaces != null)
|
||||
return;
|
||||
|
||||
Runnable startApplication = () -> {
|
||||
try {
|
||||
QtNative.startApplication(appParams, mainLib);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
m_activity.finish();
|
||||
}
|
||||
};
|
||||
initMembers(startApplication);
|
||||
initMembers();
|
||||
|
||||
m_layout.getViewTreeObserver().addOnGlobalLayoutListener(
|
||||
new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
QtNative.startApplication(appParams, mainLib);
|
||||
m_layout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initMembers(Runnable startApplicationRunnable)
|
||||
private void initMembers()
|
||||
{
|
||||
m_layout = new QtLayout(m_activity, startApplicationRunnable);
|
||||
m_layout = new QtLayout(m_activity);
|
||||
|
||||
m_displayManager.registerDisplayListener(m_activity, m_layout);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ import android.view.ViewGroup;
|
|||
|
||||
public class QtLayout extends ViewGroup
|
||||
{
|
||||
private Runnable m_startApplicationRunnable;
|
||||
|
||||
private int m_activityDisplayRotation = -1;
|
||||
private int m_ownDisplayRotation = -1;
|
||||
private int m_nativeOrientation = -1;
|
||||
|
|
@ -33,10 +31,9 @@ public class QtLayout extends ViewGroup
|
|||
return m_ownDisplayRotation;
|
||||
}
|
||||
|
||||
public QtLayout(Context context, Runnable startRunnable)
|
||||
public QtLayout(Context context)
|
||||
{
|
||||
super(context);
|
||||
m_startApplicationRunnable = startRunnable;
|
||||
}
|
||||
|
||||
public QtLayout(Context context, AttributeSet attrs)
|
||||
|
|
@ -50,7 +47,7 @@ public class QtLayout extends ViewGroup
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged (int w, int h, int oldw, int oldh)
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh)
|
||||
{
|
||||
Activity activity = (Activity)getContext();
|
||||
if (activity == null)
|
||||
|
|
@ -68,11 +65,6 @@ public class QtLayout extends ViewGroup
|
|||
QtDisplayManager.handleOrientationChanged(newRotation, m_nativeOrientation);
|
||||
}
|
||||
m_ownDisplayRotation = newRotation;
|
||||
|
||||
if (m_startApplicationRunnable != null) {
|
||||
m_startApplicationRunnable.run();
|
||||
m_startApplicationRunnable = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue