mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-03 18:26:20 +00:00
Retry browsing
This commit is contained in:
parent
38e81a3c3c
commit
305b205a98
2 changed files with 44 additions and 16 deletions
app/src/main/java/eu/faircode/email
|
@ -139,7 +139,19 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
}
|
||||
});
|
||||
if (server)
|
||||
fetched = load_server(state);
|
||||
try {
|
||||
fetched = load_server(state);
|
||||
} catch (Throwable ex) {
|
||||
if (state.error || ex instanceof IllegalArgumentException)
|
||||
throw ex;
|
||||
|
||||
Log.w("Boundary", ex);
|
||||
close();
|
||||
state.reset();
|
||||
|
||||
// Retry
|
||||
fetched = load_server(state);
|
||||
}
|
||||
else
|
||||
fetched = load_device(state);
|
||||
} catch (final Throwable ex) {
|
||||
|
@ -552,7 +564,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
return found;
|
||||
}
|
||||
|
||||
void close() {
|
||||
void destroy() {
|
||||
final State state = this.state;
|
||||
this.state = new State();
|
||||
state.destroyed = true;
|
||||
|
@ -560,23 +572,27 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.i("Boundary close");
|
||||
try {
|
||||
if (state.ifolder != null)
|
||||
state.ifolder.close();
|
||||
} catch (Throwable ex) {
|
||||
Log.e("Boundary", ex);
|
||||
}
|
||||
try {
|
||||
if (state.iservice != null)
|
||||
state.iservice.close();
|
||||
} catch (Throwable ex) {
|
||||
Log.e("Boundary", ex);
|
||||
}
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void close() {
|
||||
Log.i("Boundary close");
|
||||
try {
|
||||
if (state.ifolder != null)
|
||||
state.ifolder.close();
|
||||
} catch (Throwable ex) {
|
||||
Log.e("Boundary", ex);
|
||||
}
|
||||
try {
|
||||
if (state.iservice != null)
|
||||
state.iservice.close();
|
||||
} catch (Throwable ex) {
|
||||
Log.e("Boundary", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private class State {
|
||||
boolean destroyed = false;
|
||||
boolean error = false;
|
||||
|
@ -588,5 +604,17 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
EmailService iservice = null;
|
||||
IMAPFolder ifolder = null;
|
||||
Message[] imessages = null;
|
||||
|
||||
void reset() {
|
||||
destroyed = false;
|
||||
error = false;
|
||||
index = 0;
|
||||
offset = 0;
|
||||
ids = null;
|
||||
matches = null;
|
||||
iservice = null;
|
||||
ifolder = null;
|
||||
imessages = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -417,7 +417,7 @@ public class ViewModelMessages extends ViewModel {
|
|||
owner.getLifecycle().addObserver(new LifecycleObserver() {
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
||||
public void onDestroyed() {
|
||||
boundary.close();
|
||||
boundary.destroy();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue