@@ -193,7 +193,7 @@ protected void onPostExecute(String result) {
193193 mActivity .getPackageName (), PackageManager .GET_META_DATA ).metaData ;
194194
195195 PowerManager pm = (PowerManager ) mActivity .getSystemService (Context .POWER_SERVICE );
196- if (mActivity .mMetaData .getInt ("wakelock" ) == 1 ) {
196+ if ( mActivity .mMetaData .getInt ("wakelock" ) == 1 ) {
197197 mActivity .mWakeLock = pm .newWakeLock (PowerManager .SCREEN_BRIGHT_WAKE_LOCK , "Screen On" );
198198 mActivity .mWakeLock .acquire ();
199199 }
@@ -450,32 +450,35 @@ public void appConfirmedActive() {
450450 public void considerLoadingScreenRemoval () {
451451 if (loadingScreenRemovalTimer != null )
452452 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 () {
465463 @ Override
466464 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+ });
472475 }
473- });
476+ };
477+ loadingScreenRemovalTimer = new Timer ();
478+ loadingScreenRemovalTimer .schedule (removalTask , 5000 );
474479 }
475- };
476- loadingScreenRemovalTimer = new Timer ();
477- loadingScreenRemovalTimer .schedule (removalTask , 5000 );
478- }
480+ }
481+ });
479482 }
480483
481484 public void removeLoadingScreen () {
@@ -586,30 +589,14 @@ protected void onResume() {
586589 if (this .mWakeLock != null ) {
587590 this .mWakeLock .acquire ();
588591 }
589- Log .v (TAG , "onResume(), mSDLThread exists yet: " + ( mSDLThread != null ) );
592+ Log .v (TAG , "onResume()" );
590593 try {
591594 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- }
604595 } catch (UnsatisfiedLinkError e ) {
605596 // Catch resume while still in loading screen failing to
606597 // 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" );
609598 }
610599 considerLoadingScreenRemoval ();
611- Log .v (TAG , "onResume() done in PythonActivity, " +
612- "mSDLThread exists yet: " + (mSDLThread != null ));
613600 }
614601
615602 @ Override
@@ -619,7 +606,6 @@ public void onWindowFocusChanged(boolean hasFocus) {
619606 } catch (UnsatisfiedLinkError e ) {
620607 // Catch window focus while still in loading screen failing to
621608 // call native function (since it's not yet loaded)
622- return ; // no point in barging further
623609 }
624610 considerLoadingScreenRemoval ();
625611 }
0 commit comments