register for net state changes, and toast/log on debug builds. This is toward resending from all games with packets pending on reconnect.

This commit is contained in:
Eric House 2014-03-01 14:59:17 -08:00
parent 56c05869da
commit 23638310bc
2 changed files with 32 additions and 1 deletions

View file

@ -153,6 +153,9 @@
<string name="enable_dupes_title">Accept duplicate invites</string>
<string name="enable_dupes_summary">Accept invitations more than once</string>
<string name="net_change_gained">Network connectivity GAINED</string>
<string name="net_change_lost">Network connectivity LOST</string>
<!--string name="dict_url">http://10.0.2.2/~eehouse/and_dicts</string-->
<string-array name="board_sizes">

View file

@ -60,7 +60,8 @@ import org.eehouse.android.xw4.jni.*;
public class GamesList extends XWExpandableListActivity
implements OnItemLongClickListener,
DBUtils.DBChangeListener, SelectableItem,
DictImportActivity.DownloadFinishedListener {
DictImportActivity.DownloadFinishedListener,
NetStateCache.StateChangedIf {
private static final int WARN_NODICT = DlgDelegate.DIALOG_LAST + 1;
private static final int WARN_NODICT_SUBST = WARN_NODICT + 1;
@ -133,6 +134,7 @@ public class GamesList extends XWExpandableListActivity
private GameNamer m_namer;
private long m_launchedGame = DBUtils.ROWID_NOTFOUND;
private boolean m_menuPrepared;
private boolean m_netAvail;
private HashSet<Long> m_selGames;
private HashSet<Long> m_selGroupIDs;
private CharSequence m_origTitle;
@ -372,6 +374,8 @@ public class GamesList extends XWExpandableListActivity
CrashTrack.init( this );
m_netAvail = NetStateCache.netAvail( this );
m_selGames = new HashSet<Long>();
m_selGroupIDs = new HashSet<Long>();
getBundledData( savedInstanceState );
@ -412,9 +416,17 @@ public class GamesList extends XWExpandableListActivity
tryStartsFromIntent( intent );
}
@Override
protected void onStart()
{
super.onStart();
NetStateCache.register( this, this );
}
@Override
protected void onStop()
{
NetStateCache.unregister( this, this );
// TelephonyManager mgr =
// (TelephonyManager)getSystemService( Context.TELEPHONY_SERVICE );
// mgr.listen( m_phoneStateListener, PhoneStateListener.LISTEN_NONE );
@ -940,6 +952,22 @@ public class GamesList extends XWExpandableListActivity
} );
}
//////////////////////////////////////////////////////////////////////
// NetStateCache.StateChangedIf
//////////////////////////////////////////////////////////////////////
public void netAvail( boolean nowAvailable )
{
if ( m_netAvail != nowAvailable ) {
m_netAvail = nowAvailable;
if ( BuildConfig.DEBUG ) {
int id = nowAvailable ?
R.string.net_change_gained : R.string.net_change_lost;
Utils.showToast( this, id );
DbgUtils.logf( "GamesList.netAvail(%s)", getString( id ) );
}
}
}
private void setTitleBar()
{
int fmt = 0;