mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Boundary fixes/improvements
This commit is contained in:
parent
2e1eb95d78
commit
1e4f726dd5
2 changed files with 37 additions and 19 deletions
|
@ -81,11 +81,11 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
private IBoundaryCallbackMessages intf;
|
||||
|
||||
private Handler handler;
|
||||
private ExecutorService executor = Helper.getBackgroundExecutor(1, "boundary");
|
||||
|
||||
private State state;
|
||||
|
||||
private static final int SEARCH_LIMIT = 1000;
|
||||
private static ExecutorService executor = Helper.getBackgroundExecutor(1, "boundary");
|
||||
|
||||
interface IBoundaryCallbackMessages {
|
||||
void onLoading();
|
||||
|
@ -321,28 +321,25 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
int count = state.ifolder.getMessageCount();
|
||||
db.folder().setFolderTotal(browsable.id, count < 0 ? null : count);
|
||||
|
||||
Log.i("Boundary server query=" + criteria.query);
|
||||
if (criteria == null) {
|
||||
boolean filter_seen = prefs.getBoolean("filter_seen", false);
|
||||
boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false);
|
||||
Log.i("Boundary filter seen=" + filter_seen + " unflagged=" + filter_unflagged);
|
||||
|
||||
SearchTerm searchUnseen = null;
|
||||
if (filter_seen && state.ifolder.getPermanentFlags().contains(Flags.Flag.SEEN))
|
||||
searchUnseen = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
|
||||
List<SearchTerm> and = new ArrayList<>();
|
||||
|
||||
SearchTerm searchFlagged = null;
|
||||
if (filter_unflagged && state.ifolder.getPermanentFlags().contains(Flags.Flag.FLAGGED))
|
||||
searchFlagged = new FlagTerm(new Flags(Flags.Flag.FLAGGED), true);
|
||||
if (filter_seen &&
|
||||
state.ifolder.getPermanentFlags().contains(Flags.Flag.SEEN))
|
||||
and.add(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
|
||||
|
||||
if (searchUnseen != null && searchFlagged != null)
|
||||
state.imessages = state.ifolder.search(new AndTerm(searchUnseen, searchFlagged));
|
||||
else if (searchUnseen != null)
|
||||
state.imessages = state.ifolder.search(searchUnseen);
|
||||
else if (searchFlagged != null)
|
||||
state.imessages = state.ifolder.search(searchFlagged);
|
||||
else
|
||||
if (filter_unflagged &&
|
||||
state.ifolder.getPermanentFlags().contains(Flags.Flag.FLAGGED))
|
||||
and.add(new FlagTerm(new Flags(Flags.Flag.FLAGGED), true));
|
||||
|
||||
if (and.size() == 0)
|
||||
state.imessages = state.ifolder.getMessages();
|
||||
else
|
||||
state.imessages = state.ifolder.search(new AndTerm(and.toArray(new SearchTerm[0])));
|
||||
} else {
|
||||
Object result = state.ifolder.doCommand(new IMAPFolder.ProtocolCommand() {
|
||||
@Override
|
||||
|
@ -380,7 +377,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
|
||||
return imessages;
|
||||
} else {
|
||||
Log.i("Boundary search=" + criteria);
|
||||
Log.i("Boundary server search=" + criteria);
|
||||
|
||||
List<SearchTerm> or = new ArrayList<>();
|
||||
List<SearchTerm> and = new ArrayList<>();
|
||||
|
@ -415,9 +412,11 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
or.add(new BodyTerm(search));
|
||||
}
|
||||
|
||||
if (criteria.with_unseen)
|
||||
if (criteria.with_unseen &&
|
||||
state.ifolder.getPermanentFlags().contains(Flags.Flag.SEEN))
|
||||
and.add(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
|
||||
if (criteria.with_flagged)
|
||||
if (criteria.with_flagged &&
|
||||
state.ifolder.getPermanentFlags().contains(Flags.Flag.FLAGGED))
|
||||
and.add(new FlagTerm(new Flags(Flags.Flag.FLAGGED), true));
|
||||
|
||||
SearchTerm term = null;
|
||||
|
@ -581,6 +580,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
Message[] imessages = null;
|
||||
|
||||
void reset() {
|
||||
Log.i("Boundary reset");
|
||||
destroyed = false;
|
||||
error = false;
|
||||
index = 0;
|
||||
|
|
|
@ -48,7 +48,25 @@ import java.util.concurrent.ExecutorService;
|
|||
|
||||
public class ViewModelMessages extends ViewModel {
|
||||
private AdapterMessage.ViewType last = AdapterMessage.ViewType.UNIFIED;
|
||||
private Map<AdapterMessage.ViewType, Model> models = new HashMap<>();
|
||||
private Map<AdapterMessage.ViewType, Model> models = new HashMap<AdapterMessage.ViewType, Model>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Model put(AdapterMessage.ViewType key, Model value) {
|
||||
Model existing = this.get(key);
|
||||
if (existing != null && existing.boundary != null)
|
||||
existing.boundary.destroy();
|
||||
return super.put(key, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Model remove(@Nullable Object key) {
|
||||
Model existing = this.get(key);
|
||||
if (existing != null && existing.boundary != null)
|
||||
existing.boundary.destroy();
|
||||
return super.remove(key);
|
||||
}
|
||||
};
|
||||
|
||||
private ExecutorService executor = Helper.getBackgroundExecutor(2, "model");
|
||||
|
||||
|
|
Loading…
Reference in a new issue