Quicker transition from offline to online mode.

This commit is contained in:
dosiecki 2015-02-13 14:34:20 -08:00
parent 6471497edf
commit 4fc012b7f8
3 changed files with 27 additions and 1 deletions

View file

@ -127,6 +127,12 @@
<receiver android:name=".service.ServiceScheduleReceiver" />
<receiver android:name=".service.NetStateReceiver">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
</application>
</manifest>

View file

@ -189,7 +189,6 @@ public class NBSyncService extends Service {
try {
if (HaltNow) return;
OfflineNow = false;
incrementRunningChild();
finishConstruction();
@ -203,6 +202,11 @@ public class NBSyncService extends Service {
Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT + Process.THREAD_PRIORITY_LESS_FAVORABLE);
}
if (OfflineNow) {
NbActivity.updateAllActivities(false);
}
OfflineNow = false;
// do this even if background syncs aren't enabled, because it absolutely must happen
// on all devices
housekeeping();

View file

@ -0,0 +1,16 @@
package com.newsblur.service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class NetStateReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// poke the sync service when network state changes, in case we were offline
Intent i = new Intent(context, NBSyncService.class);
context.startService(i);
}
}