@@ -193,7 +193,7 @@ protected void onPostExecute(String result) {
193
193
mActivity .getPackageName (), PackageManager .GET_META_DATA ).metaData ;
194
194
195
195
PowerManager pm = (PowerManager ) mActivity .getSystemService (Context .POWER_SERVICE );
196
- if (mActivity .mMetaData .getInt ("wakelock" ) == 1 ) {
196
+ if ( mActivity .mMetaData .getInt ("wakelock" ) == 1 ) {
197
197
mActivity .mWakeLock = pm .newWakeLock (PowerManager .SCREEN_BRIGHT_WAKE_LOCK , "Screen On" );
198
198
mActivity .mWakeLock .acquire ();
199
199
}
@@ -450,32 +450,35 @@ public void appConfirmedActive() {
450
450
public void considerLoadingScreenRemoval () {
451
451
if (loadingScreenRemovalTimer != null )
452
452
return ;
453
- if (PythonActivity .mSingleton != null &&
454
- mAppConfirmedActive &&
455
- loadingScreenRemovalTimer == null ) {
456
- Log .v (TAG , "loading screen timer Runnable() launched." );
457
- // Remove loading screen but with a delay.
458
- // (app can use p4a's android.loadingscreen module to
459
- // do it quicker if it wants to)
460
- TimerTask removalTask = new TimerTask () {
461
- @ Override
462
- public void run () {
463
- // post a runnable to the handler
464
- runOnUiThread (new Runnable () {
453
+ runOnUiThread (new Runnable () {
454
+ public void run () {
455
+ if (((PythonActivity )PythonActivity .mSingleton ).mAppConfirmedActive &&
456
+ loadingScreenRemovalTimer == null ) {
457
+ // Remove loading screen but with a delay.
458
+ // (app can use p4a's android.loadingscreen module to
459
+ // do it quicker if it wants to)
460
+ // get a handler (call from main thread)
461
+ // this will run when timer elapses
462
+ TimerTask removalTask = new TimerTask () {
465
463
@ Override
466
464
public void run () {
467
- Log .v (TAG , "loading screen timer Runnable() finished." );
468
- PythonActivity activity =
469
- ((PythonActivity )PythonActivity .mSingleton );
470
- if (activity != null )
471
- activity .removeLoadingScreen ();
465
+ // post a runnable to the handler
466
+ runOnUiThread (new Runnable () {
467
+ @ Override
468
+ public void run () {
469
+ PythonActivity activity =
470
+ ((PythonActivity )PythonActivity .mSingleton );
471
+ if (activity != null )
472
+ activity .removeLoadingScreen ();
473
+ }
474
+ });
472
475
}
473
- });
476
+ };
477
+ loadingScreenRemovalTimer = new Timer ();
478
+ loadingScreenRemovalTimer .schedule (removalTask , 5000 );
474
479
}
475
- };
476
- loadingScreenRemovalTimer = new Timer ();
477
- loadingScreenRemovalTimer .schedule (removalTask , 5000 );
478
- }
480
+ }
481
+ });
479
482
}
480
483
481
484
public void removeLoadingScreen () {
@@ -586,30 +589,14 @@ protected void onResume() {
586
589
if (this .mWakeLock != null ) {
587
590
this .mWakeLock .acquire ();
588
591
}
589
- Log .v (TAG , "onResume(), mSDLThread exists yet: " + ( mSDLThread != null ) );
592
+ Log .v (TAG , "onResume()" );
590
593
try {
591
594
super .onResume ();
592
- if (mSDLThread == null && !mIsResumedCalled ) {
593
- // Ok so SDL2's onStart() usually launches the native code.
594
- // However, this may fail if native libs aren't loaded yet at that point
595
- // (due ot our loading screen) so we may need to manually trigger this,
596
- // otherwise code would only launch by leaving & re-entering the app:
597
- Log .v (TAG , "Loading screen workaround: triggering native resume" );
598
- if (mSDLThread == null && mCurrentNativeState == NativeState .RESUMED ) {
599
- // Force a state change so SDL2 doesn't just ignore the resume:
600
- mCurrentNativeState = NativeState .PAUSED ;
601
- }
602
- resumeNativeThread (); // native resume to call native code
603
- }
604
595
} catch (UnsatisfiedLinkError e ) {
605
596
// Catch resume while still in loading screen failing to
606
597
// call native function (since it's not yet loaded)
607
- Log .v (TAG , "failed to call native onResume() because libs " +
608
- "aren't loaded yet. this is expected to happen" );
609
598
}
610
599
considerLoadingScreenRemoval ();
611
- Log .v (TAG , "onResume() done in PythonActivity, " +
612
- "mSDLThread exists yet: " + (mSDLThread != null ));
613
600
}
614
601
615
602
@ Override
@@ -619,7 +606,6 @@ public void onWindowFocusChanged(boolean hasFocus) {
619
606
} catch (UnsatisfiedLinkError e ) {
620
607
// Catch window focus while still in loading screen failing to
621
608
// call native function (since it's not yet loaded)
622
- return ; // no point in barging further
623
609
}
624
610
considerLoadingScreenRemoval ();
625
611
}
0 commit comments