• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 package com.android.documentsui.selection.demo;
17 
18 import static android.support.v4.util.Preconditions.checkArgument;
19 
20 import com.android.documentsui.selection.SelectionHelper.StableIdProvider;
21 
22 import java.util.List;
23 
24 /**
25  * Provides RecyclerView selection code access to stable ids backed
26  * by DocumentsAdapter.
27  */
28 final class DemoStableIdProvider extends StableIdProvider {
29 
30     private final SelectionDemoAdapter mAdapter;
31 
DemoStableIdProvider(SelectionDemoAdapter adapter)32     public DemoStableIdProvider(SelectionDemoAdapter adapter) {
33         checkArgument(adapter != null);
34         mAdapter = adapter;
35     }
36 
37     @Override
getStableId(int position)38     public String getStableId(int position) {
39         return mAdapter.getStableId(position);
40     }
41 
42     @Override
getPosition(String id)43     public int getPosition(String id) {
44         return mAdapter.getPosition(id);
45     }
46 
47     @Override
getStableIds()48     public List<String> getStableIds() {
49         return mAdapter.getStableIds();
50     }
51 }
52