mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
beb2d6a1f1
commit
e99ed12590
|
@ -131,7 +131,7 @@ class Core {
|
|||
DB db = DB.getInstance(context);
|
||||
List<EntityOperation> ops = db.operation().getOperations(folder.id);
|
||||
Log.i(folder.name + " pending operations=" + ops.size());
|
||||
for (int i = 0; i < ops.size() && state.running() && state.recoverable(); i++) {
|
||||
for (int i = 0; i < ops.size() && state.isRunning() && state.isRecoverable(); i++) {
|
||||
EntityOperation op = ops.get(i);
|
||||
try {
|
||||
Log.i(folder.name +
|
||||
|
@ -1109,7 +1109,7 @@ class Core {
|
|||
}
|
||||
});
|
||||
|
||||
for (int i = 0; i < imessages.length && state.running() && state.recoverable(); i++)
|
||||
for (int i = 0; i < imessages.length && state.isRunning() && state.isRecoverable(); i++)
|
||||
try {
|
||||
uids.remove(ifolder.getUID(imessages[i]));
|
||||
} catch (MessageRemovedException ex) {
|
||||
|
@ -1212,7 +1212,7 @@ class Core {
|
|||
// Add/update local messages
|
||||
Long[] ids = new Long[imessages.length];
|
||||
Log.i(folder.name + " add=" + imessages.length);
|
||||
for (int i = imessages.length - 1; i >= 0 && state.running() && state.recoverable(); i -= SYNC_BATCH_SIZE) {
|
||||
for (int i = imessages.length - 1; i >= 0 && state.isRunning() && state.isRecoverable(); i -= SYNC_BATCH_SIZE) {
|
||||
int from = Math.max(0, i - SYNC_BATCH_SIZE + 1);
|
||||
Message[] isub = Arrays.copyOfRange(imessages, from, i + 1);
|
||||
|
||||
|
@ -1239,7 +1239,7 @@ class Core {
|
|||
Log.breadcrumb("sync", crumb);
|
||||
Log.i("Sync " + from + ".." + i + " free=" + free);
|
||||
|
||||
for (int j = isub.length - 1; j >= 0 && state.running() && state.recoverable(); j--)
|
||||
for (int j = isub.length - 1; j >= 0 && state.isRunning() && state.isRecoverable(); j--)
|
||||
try {
|
||||
// Some providers, like Zoho, erroneously return old messages
|
||||
if (full.contains(isub[j])) {
|
||||
|
@ -1304,7 +1304,7 @@ class Core {
|
|||
|
||||
// Download messages/attachments
|
||||
Log.i(folder.name + " download=" + imessages.length);
|
||||
for (int i = imessages.length - 1; i >= 0 && state.running() && state.recoverable(); i -= DOWNLOAD_BATCH_SIZE) {
|
||||
for (int i = imessages.length - 1; i >= 0 && state.isRunning() && state.isRecoverable(); i -= DOWNLOAD_BATCH_SIZE) {
|
||||
int from = Math.max(0, i - DOWNLOAD_BATCH_SIZE + 1);
|
||||
|
||||
Message[] isub = Arrays.copyOfRange(imessages, from, i + 1);
|
||||
|
@ -1318,7 +1318,7 @@ class Core {
|
|||
Log.breadcrumb("download", crumb);
|
||||
Log.i("Download " + from + ".." + i + " free=" + free);
|
||||
|
||||
for (int j = isub.length - 1; j >= 0 && state.running() && state.recoverable(); j--)
|
||||
for (int j = isub.length - 1; j >= 0 && state.isRunning() && state.isRecoverable(); j--)
|
||||
try {
|
||||
if (ids[from + j] != null)
|
||||
downloadMessage(
|
||||
|
@ -2474,11 +2474,11 @@ class Core {
|
|||
join(thread);
|
||||
}
|
||||
|
||||
boolean running() {
|
||||
boolean isRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
boolean recoverable() {
|
||||
boolean isRecoverable() {
|
||||
return recoverable;
|
||||
}
|
||||
|
||||
|
|
|
@ -618,7 +618,7 @@ public class ServiceSynchronize extends ServiceBase {
|
|||
final DB db = DB.getInstance(this);
|
||||
|
||||
int backoff = CONNECT_BACKOFF_START;
|
||||
while (state.running()) {
|
||||
while (state.isRunning()) {
|
||||
state.reset();
|
||||
Log.i(account.name + " run");
|
||||
|
||||
|
@ -1012,7 +1012,7 @@ public class ServiceSynchronize extends ServiceBase {
|
|||
public void run() {
|
||||
try {
|
||||
Log.i(folder.name + " start idle");
|
||||
while (state.running() && state.recoverable()) {
|
||||
while (state.isRunning() && state.isRecoverable()) {
|
||||
Log.i(folder.name + " do idle");
|
||||
ifolder.idle(false);
|
||||
}
|
||||
|
@ -1154,8 +1154,8 @@ public class ServiceSynchronize extends ServiceBase {
|
|||
// Keep alive
|
||||
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
try {
|
||||
while (state.running()) {
|
||||
if (!state.recoverable())
|
||||
while (state.isRunning()) {
|
||||
if (!state.isRecoverable())
|
||||
throw new StoreClosedException(iservice.getStore(), "Unrecoverable");
|
||||
|
||||
// Sends store NOOP
|
||||
|
@ -1259,7 +1259,7 @@ public class ServiceSynchronize extends ServiceBase {
|
|||
db.folder().setFolderState(folder.id, null);
|
||||
}
|
||||
|
||||
if (state.running())
|
||||
if (state.isRunning())
|
||||
try {
|
||||
if (backoff <= CONNECT_BACKOFF_MAX) {
|
||||
// Short back-off period, keep device awake
|
||||
|
|
Loading…
Reference in New Issue