Moved sync logic. code broken. =)

pull/14/head
Tim Su 17 years ago
parent 25e8e63525
commit 37340b6cb2

@ -14,9 +14,6 @@ import com.timsu.astrid.utilities.DialogUtilities;
public class SyncPreferences extends PreferenceActivity {
private static boolean syncFinished = true;
private Button syncButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -27,25 +24,12 @@ public class SyncPreferences extends PreferenceActivity {
getListView().addFooterView(getLayoutInflater().inflate(
R.layout.sync_footer, getListView(), false));
syncButton = ((Button)findViewById(R.id.sync));
Button syncButton = ((Button)findViewById(R.id.sync));
syncButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
syncButton.setEnabled(false);
syncFinished = false;
Synchronizer.synchronize(SyncPreferences.this, new SynchronizerListener() {
@Override
public void onSynchronizerFinished(int numServicesSynced) {
syncButton.setEnabled(true);
syncFinished = true;
if(numServicesSynced == 0) {
DialogUtilities.okDialog(SyncPreferences.this,
"Nothing to do!", null);
} else {
finish();
}
}
});
Preferences.setSyncLastSync(SyncPreferences.this, null);
finish();
}
});
@ -64,9 +48,4 @@ public class SyncPreferences extends PreferenceActivity {
}
});
}
protected void onResume() {
super.onResume();
syncButton.setEnabled(syncFinished);
}
}

@ -151,11 +151,13 @@ public class TaskList extends Activity {
// auto sync
Integer autoSyncHours = Preferences.autoSyncFrequency(this);
if(autoSyncHours != null) {
Date lastSync = Preferences.getSyncLastSync(this);
final Date lastSync = Preferences.getSyncLastSync(this);
if(lastSync == null || lastSync.getTime() +
1000L*3600*autoSyncHours < System.currentTimeMillis()) {
Synchronizer.synchronize(this, null);
Synchronizer.synchronize(this, new SynchronizationListener() {
show dialog!
});
}
}
}

Loading…
Cancel
Save