diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml
index ab0d93a49..7b2395bf6 100644
--- a/xwords4/android/XWords4/res/values/common_rsrc.xml
+++ b/xwords4/android/XWords4/res/values/common_rsrc.xml
@@ -153,6 +153,9 @@
Accept duplicate invites
Accept invitations more than once
+ Network connectivity GAINED
+ Network connectivity LOST
+
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
index 2c5fb618b..b9539178d 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java
@@ -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 m_selGames;
private HashSet 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();
m_selGroupIDs = new HashSet();
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;