mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
resend all messages from the network change broadcast receiver itself instead of GamesList, which will not be listening if another activity is in front or if the app's in the background.
This commit is contained in:
parent
3c0b4a899f
commit
cfee7ef8ac
3 changed files with 7 additions and 37 deletions
|
@ -153,9 +153,6 @@
|
||||||
<string name="enable_dupes_title">Accept duplicate invites</string>
|
<string name="enable_dupes_title">Accept duplicate invites</string>
|
||||||
<string name="enable_dupes_summary">Accept invitations more than once</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 name="dict_url">http://10.0.2.2/~eehouse/and_dicts</string-->
|
||||||
|
|
||||||
<string-array name="board_sizes">
|
<string-array name="board_sizes">
|
||||||
|
|
|
@ -60,8 +60,7 @@ import org.eehouse.android.xw4.jni.*;
|
||||||
public class GamesList extends XWExpandableListActivity
|
public class GamesList extends XWExpandableListActivity
|
||||||
implements OnItemLongClickListener,
|
implements OnItemLongClickListener,
|
||||||
DBUtils.DBChangeListener, SelectableItem,
|
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 = DlgDelegate.DIALOG_LAST + 1;
|
||||||
private static final int WARN_NODICT_SUBST = WARN_NODICT + 1;
|
private static final int WARN_NODICT_SUBST = WARN_NODICT + 1;
|
||||||
|
@ -135,7 +134,6 @@ public class GamesList extends XWExpandableListActivity
|
||||||
private GameNamer m_namer;
|
private GameNamer m_namer;
|
||||||
private long m_launchedGame = DBUtils.ROWID_NOTFOUND;
|
private long m_launchedGame = DBUtils.ROWID_NOTFOUND;
|
||||||
private boolean m_menuPrepared;
|
private boolean m_menuPrepared;
|
||||||
private boolean m_netAvail;
|
|
||||||
private HashSet<Long> m_selGames;
|
private HashSet<Long> m_selGames;
|
||||||
private HashSet<Long> m_selGroupIDs;
|
private HashSet<Long> m_selGroupIDs;
|
||||||
private CharSequence m_origTitle;
|
private CharSequence m_origTitle;
|
||||||
|
@ -375,8 +373,6 @@ public class GamesList extends XWExpandableListActivity
|
||||||
|
|
||||||
CrashTrack.init( this );
|
CrashTrack.init( this );
|
||||||
|
|
||||||
m_netAvail = NetStateCache.netAvail( this );
|
|
||||||
|
|
||||||
m_selGames = new HashSet<Long>();
|
m_selGames = new HashSet<Long>();
|
||||||
m_selGroupIDs = new HashSet<Long>();
|
m_selGroupIDs = new HashSet<Long>();
|
||||||
getBundledData( savedInstanceState );
|
getBundledData( savedInstanceState );
|
||||||
|
@ -417,17 +413,9 @@ public class GamesList extends XWExpandableListActivity
|
||||||
tryStartsFromIntent( intent );
|
tryStartsFromIntent( intent );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart()
|
|
||||||
{
|
|
||||||
super.onStart();
|
|
||||||
NetStateCache.register( this, this );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
NetStateCache.unregister( this, this );
|
|
||||||
// TelephonyManager mgr =
|
// TelephonyManager mgr =
|
||||||
// (TelephonyManager)getSystemService( Context.TELEPHONY_SERVICE );
|
// (TelephonyManager)getSystemService( Context.TELEPHONY_SERVICE );
|
||||||
// mgr.listen( m_phoneStateListener, PhoneStateListener.LISTEN_NONE );
|
// mgr.listen( m_phoneStateListener, PhoneStateListener.LISTEN_NONE );
|
||||||
|
@ -956,23 +944,6 @@ 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 ) );
|
|
||||||
}
|
|
||||||
GameUtils.resendAllIf( this, false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setTitleBar()
|
private void setTitleBar()
|
||||||
{
|
{
|
||||||
int fmt = 0;
|
int fmt = 0;
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class NetStateCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive( Context context, Intent intent )
|
public void onReceive( final Context context, Intent intent )
|
||||||
{
|
{
|
||||||
DbgUtils.assertOnUIThread();
|
DbgUtils.assertOnUIThread();
|
||||||
|
|
||||||
|
@ -117,8 +117,6 @@ public class NetStateCache {
|
||||||
NetworkInfo ni = (NetworkInfo)intent.
|
NetworkInfo ni = (NetworkInfo)intent.
|
||||||
getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
|
getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
|
||||||
NetworkInfo.State state = ni.getState();
|
NetworkInfo.State state = ni.getState();
|
||||||
DbgUtils.logf( "PvtBroadcastReceiver.onReceive: "
|
|
||||||
+ "new network state: %s", state.toString() );
|
|
||||||
|
|
||||||
boolean netAvail;
|
boolean netAvail;
|
||||||
switch ( state ) {
|
switch ( state ) {
|
||||||
|
@ -151,15 +149,19 @@ public class NetStateCache {
|
||||||
mNotifyLater = new Runnable() {
|
mNotifyLater = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DbgUtils.logf( "PvtBroadcastReceiver: run() fired." );
|
|
||||||
Assert.assertTrue( mLastStateSent != s_netAvail );
|
Assert.assertTrue( mLastStateSent != s_netAvail );
|
||||||
mLastStateSent = s_netAvail;
|
mLastStateSent = s_netAvail;
|
||||||
|
|
||||||
synchronized( s_ifs ) {
|
synchronized( s_ifs ) {
|
||||||
Iterator<StateChangedIf> iter = s_ifs.iterator();
|
Iterator<StateChangedIf> iter = s_ifs.iterator();
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
iter.next().netAvail( s_netAvail );
|
iter.next().netAvail( s_netAvail );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( s_netAvail ) {
|
||||||
|
GameUtils.resendAllIf( context, false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mHandler.postDelayed( mNotifyLater, WAIT_STABLE_MILLIS );
|
mHandler.postDelayed( mNotifyLater, WAIT_STABLE_MILLIS );
|
||||||
|
|
Loading…
Reference in a new issue