Always reset boundary after close

pull/178/head
M66B 5 years ago
parent ee918757a3
commit b67e359c6d

@ -113,23 +113,26 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
@Override @Override
public void onZeroItemsLoaded() { public void onZeroItemsLoaded() {
Log.i("Boundary zero loaded"); Log.i("Boundary zero loaded");
queue_load(); queue_load(state);
} }
@Override @Override
public void onItemAtEndLoaded(@NonNull final TupleMessageEx itemAtEnd) { public void onItemAtEndLoaded(@NonNull final TupleMessageEx itemAtEnd) {
Log.i("Boundary at end"); Log.i("Boundary at end");
queue_load(); queue_load(state);
} }
void retry() { void retry() {
state.reset(); executor.submit(new Runnable() {
queue_load(); @Override
public void run() {
close(state);
}
});
queue_load(state);
} }
private void queue_load() { private void queue_load(final State state) {
final State state = this.state;
executor.submit(new Runnable() { executor.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -152,8 +155,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
throw ex; throw ex;
Log.w("Boundary", ex); Log.w("Boundary", ex);
close(); close(state);
state.reset();
// Retry // Retry
load_server(state); load_server(state);
@ -539,32 +541,37 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
} }
void destroy() { void destroy() {
final State state = this.state; final State old = this.state;
old.destroyed = true;
this.state = new State(); this.state = new State();
state.destroyed = true;
executor.submit(new Runnable() { executor.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
close(); close(old);
} }
}); });
} }
private void close() { private void close(State state) {
Log.i("Boundary close"); Log.i("Boundary close");
try { try {
if (state.ifolder != null) if (state.ifolder != null)
state.ifolder.close(); state.ifolder.close();
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e("Boundary", ex); Log.e("Boundary", ex);
} }
try { try {
if (state.iservice != null) if (state.iservice != null)
state.iservice.close(); state.iservice.close();
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e("Boundary", ex); Log.e("Boundary", ex);
} }
state.reset();
} }
private class State { private class State {

Loading…
Cancel
Save