1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 18:27:43 +00:00

Fixed prev/next fallback

This commit is contained in:
M66B 2021-08-02 07:03:54 +02:00
parent c191b18fc7
commit 6a3de2621d

View file

@ -301,14 +301,20 @@ public class ViewModelMessages extends ViewModel {
return;
}
Log.i("Observe previous/next" +
" prev=" + (curState[0] == null ? null : curState[0].first + "/" + curState[0].second) +
" base=" + (curState[1] == null ? null : curState[1].first + "/" + curState[1].second) +
" next=" + (curState[2] == null ? null : curState[2].first + "/" + curState[2].second));
lastState[0] = curState[0];
lastState[1] = curState[1];
lastState[2] = curState[2];
if (curState[1] != null)
if (curState[1] != null) {
intf.onFound(curState[1].second, messages.size());
intf.onPrevious(curState[0] != null, curState[0] == null ? null : curState[0].first);
intf.onNext(curState[2] != null, curState[2] == null ? null : curState[2].first);
intf.onPrevious(curState[0] != null, curState[0] == null ? null : curState[0].first);
intf.onNext(curState[2] != null, curState[2] == null ? null : curState[2].first);
}
if (curState[1] != null &&
(curState[0] == null || curState[0].first != null) &&
@ -355,6 +361,23 @@ public class ViewModelMessages extends ViewModel {
return null;
}
@Override
protected void onExecuted(Bundle args, Pair<Long, Long> data) {
if (data == null) {
Log.i("Observe previous/next fallback=none");
return; // keep current
}
intf.onPrevious(data.first != null, data.first);
intf.onNext(data.second != null, data.second);
intf.onFound(-1, messages.size());
}
@Override
protected void onException(Bundle args, Throwable ex) {
// No nothing
}
private Pair<Long, Long> getPair(
PagedList<TupleMessageEx> plist,
LimitOffsetDataSource<TupleMessageEx> ds,
@ -379,18 +402,6 @@ public class ViewModelMessages extends ViewModel {
Log.i("Observe previous/next fallback=" + result);
return result;
}
@Override
protected void onExecuted(Bundle args, Pair<Long, Long> data) {
intf.onPrevious(data != null && data.first != null, data == null ? null : data.first);
intf.onNext(data != null && data.second != null, data == null ? null : data.second);
intf.onFound(-1, messages.size());
}
@Override
protected void onException(Bundle args, Throwable ex) {
// No nothing
}
}.execute(context, owner, args, "model:fallback");
}
});