1/*
2 * Copyright 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package androidx.paging;
18
19import androidx.annotation.NonNull;
20import androidx.annotation.Nullable;
21
22class SnapshotPagedList<T> extends PagedList<T> {
23    private final boolean mContiguous;
24    private final Object mLastKey;
25    private final DataSource<?, T> mDataSource;
26
27    SnapshotPagedList(@NonNull PagedList<T> pagedList) {
28        super(pagedList.mStorage.snapshot(),
29                pagedList.mMainThreadExecutor,
30                pagedList.mBackgroundThreadExecutor,
31                null,
32                pagedList.mConfig);
33        mDataSource = pagedList.getDataSource();
34        mContiguous = pagedList.isContiguous();
35        mLastKey = pagedList.getLastKey();
36    }
37
38    @Override
39    public boolean isImmutable() {
40        return true;
41    }
42
43    @Override
44    public boolean isDetached() {
45        return true;
46    }
47
48    @Override
49    boolean isContiguous() {
50        return mContiguous;
51    }
52
53    @Nullable
54    @Override
55    public Object getLastKey() {
56        return mLastKey;
57    }
58
59    @NonNull
60    @Override
61    public DataSource<?, T> getDataSource() {
62        return mDataSource;
63    }
64
65    @Override
66    void dispatchUpdatesSinceSnapshot(@NonNull PagedList<T> storageSnapshot,
67            @NonNull Callback callback) {
68    }
69
70    @Override
71    void loadAroundInternal(int index) {
72    }
73}
74