mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Quicker transition from offline to online mode.
This commit is contained in:
parent
6471497edf
commit
4fc012b7f8
3 changed files with 27 additions and 1 deletions
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue