mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Fix the same value, null, was passed as the nextKey in two sequential Pages loaded from a PagingSource.
This commit is contained in:
parent
8a10733d8c
commit
7f44b6a8de
@ -1,7 +1,6 @@
|
|||||||
package ml.docilealligator.infinityforreddit.post;
|
package ml.docilealligator.infinityforreddit.post;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.paging.ListenableFuturePagingSource;
|
import androidx.paging.ListenableFuturePagingSource;
|
||||||
@ -157,7 +156,6 @@ public class PostPagingSource extends ListenableFuturePagingSource<String, Post>
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public String getRefreshKey(@NonNull PagingState<String, Post> pagingState) {
|
public String getRefreshKey(@NonNull PagingState<String, Post> pagingState) {
|
||||||
Log.i("asdfad", "asdf " + sortType.getType().value);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +190,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<String, Post>
|
|||||||
int currentPostsSize = postLinkedHashSet.size();
|
int currentPostsSize = postLinkedHashSet.size();
|
||||||
postLinkedHashSet.addAll(newPosts);
|
postLinkedHashSet.addAll(newPosts);
|
||||||
if (currentPostsSize == postLinkedHashSet.size()) {
|
if (currentPostsSize == postLinkedHashSet.size()) {
|
||||||
return new LoadResult.Page<>(new ArrayList<>(), null, lastItem);
|
return new LoadResult.Page<>(new ArrayList<>(), null, null);
|
||||||
} else {
|
} else {
|
||||||
return new LoadResult.Page<>(new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()), null, lastItem);
|
return new LoadResult.Page<>(new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()), null, lastItem);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user