mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-28 10:47:28 +00:00
Fixed prev/next fallback
This commit is contained in:
parent
c191b18fc7
commit
6a3de2621d
1 changed files with 26 additions and 15 deletions
|
@ -301,14 +301,20 @@ public class ViewModelMessages extends ViewModel {
|
||||||
return;
|
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[0] = curState[0];
|
||||||
lastState[1] = curState[1];
|
lastState[1] = curState[1];
|
||||||
lastState[2] = curState[2];
|
lastState[2] = curState[2];
|
||||||
|
|
||||||
if (curState[1] != null)
|
if (curState[1] != null) {
|
||||||
intf.onFound(curState[1].second, messages.size());
|
intf.onFound(curState[1].second, messages.size());
|
||||||
intf.onPrevious(curState[0] != null, curState[0] == null ? null : curState[0].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);
|
intf.onNext(curState[2] != null, curState[2] == null ? null : curState[2].first);
|
||||||
|
}
|
||||||
|
|
||||||
if (curState[1] != null &&
|
if (curState[1] != null &&
|
||||||
(curState[0] == null || curState[0].first != null) &&
|
(curState[0] == null || curState[0].first != null) &&
|
||||||
|
@ -355,6 +361,23 @@ public class ViewModelMessages extends ViewModel {
|
||||||
return null;
|
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(
|
private Pair<Long, Long> getPair(
|
||||||
PagedList<TupleMessageEx> plist,
|
PagedList<TupleMessageEx> plist,
|
||||||
LimitOffsetDataSource<TupleMessageEx> ds,
|
LimitOffsetDataSource<TupleMessageEx> ds,
|
||||||
|
@ -379,18 +402,6 @@ public class ViewModelMessages extends ViewModel {
|
||||||
Log.i("Observe previous/next fallback=" + result);
|
Log.i("Observe previous/next fallback=" + result);
|
||||||
return 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");
|
}.execute(context, owner, args, "model:fallback");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue