Removed widget update delay

This commit is contained in:
M66B 2020-06-16 11:33:28 +02:00
parent 74d15a99f4
commit 8443fd469d
1 changed files with 3 additions and 24 deletions

View File

@ -95,7 +95,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private long lastLost = 0; private long lastLost = 0;
private int lastAccounts = 0; private int lastAccounts = 0;
private int lastOperations = 0; private int lastOperations = 0;
private Handler handler;
private Map<Long, Core.State> coreStates = new Hashtable<>(); private Map<Long, Core.State> coreStates = new Hashtable<>();
private MutableLiveData<ConnectionHelper.NetworkState> liveNetworkState = new MutableLiveData<>(); private MutableLiveData<ConnectionHelper.NetworkState> liveNetworkState = new MutableLiveData<>();
@ -115,7 +114,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private static final int ACCOUNT_ERROR_AFTER = 60; // minutes private static final int ACCOUNT_ERROR_AFTER = 60; // minutes
private static final int ACCOUNT_ERROR_AFTER_POLL = 3; // times private static final int ACCOUNT_ERROR_AFTER_POLL = 3; // times
private static final int BACKOFF_ERROR_AFTER = 16; // seconds private static final int BACKOFF_ERROR_AFTER = 16; // seconds
private static final long WIDGET_UPDATE_DELAY = 1500L; // milliseconds
private static final String ACTION_NEW_MESSAGE_COUNT = BuildConfig.APPLICATION_ID + ".NEW_MESSAGE_COUNT"; private static final String ACTION_NEW_MESSAGE_COUNT = BuildConfig.APPLICATION_ID + ".NEW_MESSAGE_COUNT";
@ -147,8 +145,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
else else
startForeground(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(null, null).build()); startForeground(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(null, null).build());
handler = new Handler();
// Listen for network changes // Listen for network changes
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkRequest.Builder builder = new NetworkRequest.Builder(); NetworkRequest.Builder builder = new NetworkRequest.Builder();
@ -530,8 +526,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
last = stats; last = stats;
handler.removeCallbacks(refreshWidget); Widget.update(ServiceSynchronize.this);
handler.postDelayed(refreshWidget, WIDGET_UPDATE_DELAY);
boolean badge = prefs.getBoolean("badge", true); boolean badge = prefs.getBoolean("badge", true);
boolean unseen_ignored = prefs.getBoolean("unseen_ignored", false); boolean unseen_ignored = prefs.getBoolean("unseen_ignored", false);
@ -585,10 +580,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
break; break;
} }
if (changed) { if (changed)
handler.removeCallbacks(refreshWidgetUnified); WidgetUnified.updateData(ServiceSynchronize.this);
handler.postDelayed(refreshWidgetUnified, WIDGET_UPDATE_DELAY);
}
last = current; last = current;
} }
@ -597,20 +590,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
prefs.registerOnSharedPreferenceChangeListener(this); prefs.registerOnSharedPreferenceChangeListener(this);
} }
private final Runnable refreshWidget = new Runnable() {
@Override
public void run() {
Widget.update(ServiceSynchronize.this);
}
};
private final Runnable refreshWidgetUnified = new Runnable() {
@Override
public void run() {
WidgetUnified.updateData(ServiceSynchronize.this);
}
};
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (PREF_EVAL.contains(key)) { if (PREF_EVAL.contains(key)) {