Don't get stuck in sync thread loop when not logged in--wastes memory

pull/14/head
Sam Bosley 12 years ago
parent c1f1681bc0
commit e8dedefc7c

@ -63,6 +63,7 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmInvoker;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.actfm.sync.ActFmServiceException;
import com.todoroo.astrid.actfm.sync.ActFmSyncMonitor;
import com.todoroo.astrid.activity.Eula;
import com.todoroo.astrid.gtasks.auth.ModernAuthManager;
import com.todoroo.astrid.service.AstridDependencyInjector;
@ -569,6 +570,11 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
ActFmPreferenceService.reloadThisUser();
ActFmSyncMonitor monitor = ActFmSyncMonitor.getInstance();
synchronized (monitor) {
monitor.notifyAll();
}
setResult(RESULT_OK);
finish();

@ -128,7 +128,7 @@ public class ActFmSyncThread {
List<ClientToServerMessage<?>> messageBatch = new LinkedList<ClientToServerMessage<?>>();
while(true) {
synchronized(monitor) {
while (pendingMessages.isEmpty() && !timeForBackgroundSync()) {
while ((pendingMessages.isEmpty() && !timeForBackgroundSync()) || !actFmPreferenceService.isLoggedIn()) {
try {
monitor.wait();
} catch (InterruptedException e) {

Loading…
Cancel
Save