diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java index cd524009f..3fbd3a0b6 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java @@ -38,6 +38,7 @@ import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.EditText; import android.widget.TextView; +import java.util.ArrayList; import org.eehouse.android.xw4.DlgDelegate.Action; import org.eehouse.android.xw4.DlgDelegate.ActionPair; @@ -58,6 +59,7 @@ public class DelegateBase implements DlgClickNotify, private int m_layoutID; private View m_rootView; private boolean m_isVisible; + private ArrayList m_visibleProcs = new ArrayList(); public DelegateBase( Delegator delegator, Bundle bundle, int layoutID ) { @@ -116,6 +118,7 @@ public class DelegateBase implements DlgClickNotify, { m_isVisible = true; XWService.setListener( this ); + runIfVisible(); } protected void onPause() @@ -274,6 +277,16 @@ public class DelegateBase implements DlgClickNotify, return result; } + private void runIfVisible() + { + if ( isVisible() ) { + for ( Runnable proc : m_visibleProcs ) { + post( proc ); + } + m_visibleProcs.clear(); + } + } + protected String getString( int resID, Object... params ) { return LocUtils.getString( m_activity, resID, params ); @@ -601,6 +614,12 @@ public class DelegateBase implements DlgClickNotify, return false; // not handled } + protected void runWhenActive( Runnable proc ) + { + m_visibleProcs.add( proc ); + runIfVisible(); + } + ////////////////////////////////////////////////// // MultiService.MultiEventListener interface ////////////////////////////////////////////////// diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java index 0b3b0bc65..da3cc9843 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java @@ -1595,7 +1595,7 @@ public class GamesListDelegate extends ListDelegateBase public void downloadFinished( String lang, String name, final boolean success ) { - post( new Runnable() { + runWhenActive( new Runnable() { public void run() { boolean madeGame = false; if ( success ) {