mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-04 02:28:18 +00:00
Retry browsing
This commit is contained in:
parent
38e81a3c3c
commit
305b205a98
2 changed files with 44 additions and 16 deletions
|
@ -139,7 +139,19 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (server)
|
if (server)
|
||||||
|
try {
|
||||||
fetched = load_server(state);
|
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
|
else
|
||||||
fetched = load_device(state);
|
fetched = load_device(state);
|
||||||
} catch (final Throwable ex) {
|
} catch (final Throwable ex) {
|
||||||
|
@ -552,7 +564,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
void close() {
|
void destroy() {
|
||||||
final State state = this.state;
|
final State state = this.state;
|
||||||
this.state = new State();
|
this.state = new State();
|
||||||
state.destroyed = true;
|
state.destroyed = true;
|
||||||
|
@ -560,6 +572,12 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||||
executor.submit(new Runnable() {
|
executor.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void close() {
|
||||||
Log.i("Boundary close");
|
Log.i("Boundary close");
|
||||||
try {
|
try {
|
||||||
if (state.ifolder != null)
|
if (state.ifolder != null)
|
||||||
|
@ -574,8 +592,6 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||||
Log.e("Boundary", ex);
|
Log.e("Boundary", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private class State {
|
private class State {
|
||||||
boolean destroyed = false;
|
boolean destroyed = false;
|
||||||
|
@ -588,5 +604,17 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||||
EmailService iservice = null;
|
EmailService iservice = null;
|
||||||
IMAPFolder ifolder = null;
|
IMAPFolder ifolder = null;
|
||||||
Message[] imessages = 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() {
|
owner.getLifecycle().addObserver(new LifecycleObserver() {
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
||||||
public void onDestroyed() {
|
public void onDestroyed() {
|
||||||
boundary.close();
|
boundary.destroy();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue