mirror of https://github.com/M66B/FairEmail.git
Simplified search control
This commit is contained in:
parent
b64ea1bc85
commit
88dfe0dc82
|
@ -119,20 +119,13 @@ 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(state, null);
|
queue_load(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemAtEndLoaded(@NonNull final TupleMessageEx itemAtEnd) {
|
public void onItemAtEndLoaded(@NonNull final TupleMessageEx itemAtEnd) {
|
||||||
Long id = (itemAtEnd == null ? null : itemAtEnd.id); // fall-safe
|
Log.i("Boundary at end id=" + itemAtEnd.id);
|
||||||
|
queue_load(state);
|
||||||
if (state.end != null && state.end.equals(id)) {
|
|
||||||
Log.i("Boundary at same end=" + id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.i("Boundary at end=" + id);
|
|
||||||
queue_load(state, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void retry() {
|
void retry() {
|
||||||
|
@ -142,20 +135,20 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||||
close(state, true);
|
close(state, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
queue_load(state, null);
|
queue_load(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void queue_load(final State state, Long end) {
|
private void queue_load(final State state) {
|
||||||
state.end = end;
|
if (state.queued > 1) {
|
||||||
|
Log.i("Boundary queued =" + state.queued);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.queued++;
|
||||||
|
Log.i("Boundary queued +" + state.queued);
|
||||||
|
|
||||||
executor.submit(new Runnable() {
|
executor.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (end != null && state.end != null && !state.end.equals(end)) {
|
|
||||||
Log.i("Boundary end=" + state.end + "/" + end);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Helper.gc();
|
Helper.gc();
|
||||||
|
|
||||||
int free = Log.getFreeMemMb();
|
int free = Log.getFreeMemMb();
|
||||||
|
@ -163,7 +156,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||||
crumb.put("free", Integer.toString(free));
|
crumb.put("free", Integer.toString(free));
|
||||||
Log.breadcrumb("Boundary run", crumb);
|
Log.breadcrumb("Boundary run", crumb);
|
||||||
|
|
||||||
Log.i("Boundary run end=" + state.end + "/" + end + " free=" + free);
|
Log.i("Boundary run free=" + free);
|
||||||
|
|
||||||
int found = 0;
|
int found = 0;
|
||||||
try {
|
try {
|
||||||
|
@ -203,6 +196,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
|
state.queued--;
|
||||||
|
Log.i("Boundary queued -" + state.queued);
|
||||||
Helper.gc();
|
Helper.gc();
|
||||||
|
|
||||||
crumb.put("free", Integer.toString(Log.getFreeMemMb()));
|
crumb.put("free", Integer.toString(Log.getFreeMemMb()));
|
||||||
|
@ -536,14 +531,13 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||||
long uid = state.ifolder.getUID(isub[j]);
|
long uid = state.ifolder.getUID(isub[j]);
|
||||||
Log.i("Boundary server sync uid=" + uid);
|
Log.i("Boundary server sync uid=" + uid);
|
||||||
EntityMessage message = db.message().getMessageByUid(browsable.id, uid);
|
EntityMessage message = db.message().getMessageByUid(browsable.id, uid);
|
||||||
if (message == null) {
|
if (message == null)
|
||||||
message = Core.synchronizeMessage(context,
|
message = Core.synchronizeMessage(context,
|
||||||
account, browsable,
|
account, browsable,
|
||||||
(IMAPStore) state.iservice.getStore(), state.ifolder, (MimeMessage) isub[j],
|
(IMAPStore) state.iservice.getStore(), state.ifolder, (MimeMessage) isub[j],
|
||||||
true, true,
|
true, true,
|
||||||
rules, astate, null);
|
rules, astate, null);
|
||||||
found++;
|
found++;
|
||||||
}
|
|
||||||
if (message != null && criteria != null /* browsed */)
|
if (message != null && criteria != null /* browsed */)
|
||||||
db.message().setMessageFound(message.id);
|
db.message().setMessageFound(message.id);
|
||||||
} catch (MessageRemovedException ex) {
|
} catch (MessageRemovedException ex) {
|
||||||
|
@ -647,11 +641,11 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class State {
|
private static class State {
|
||||||
|
int queued = 0;
|
||||||
boolean destroyed = false;
|
boolean destroyed = false;
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
Long end = null;
|
|
||||||
List<Long> ids = null;
|
List<Long> ids = null;
|
||||||
List<TupleMatch> matches = null;
|
List<TupleMatch> matches = null;
|
||||||
|
|
||||||
|
@ -661,11 +655,11 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
Log.i("Boundary reset");
|
Log.i("Boundary reset");
|
||||||
|
queued = 0;
|
||||||
destroyed = false;
|
destroyed = false;
|
||||||
error = false;
|
error = false;
|
||||||
index = 0;
|
index = 0;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
end = null;
|
|
||||||
ids = null;
|
ids = null;
|
||||||
matches = null;
|
matches = null;
|
||||||
iservice = null;
|
iservice = null;
|
||||||
|
|
Loading…
Reference in New Issue