blob: 3d0f2530f26d6327d35d4e1c50305febc786045a [file] [log] [blame]
Garfield Tan84bd0f12016-09-12 14:18:32 -07001/*
2 * Copyright (C) 2016 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 com.android.documentsui.testing;
18
Garfield Tan84bd0f12016-09-12 14:18:32 -070019import com.android.documentsui.dirlist.TestDocumentsAdapter;
Steve McKay4f78ba62016-10-04 16:48:49 -070020import com.android.documentsui.selection.SelectionManager;
21import com.android.documentsui.selection.SelectionManager.SelectionMode;
22import com.android.documentsui.selection.SelectionManager.SelectionPredicate;
Garfield Tan84bd0f12016-09-12 14:18:32 -070023
24import java.util.Collections;
25import java.util.List;
26
27public class MultiSelectManagers {
28 private MultiSelectManagers() {}
29
Steve McKay4f78ba62016-10-04 16:48:49 -070030 public static SelectionManager createTestInstance() {
Garfield Tan84bd0f12016-09-12 14:18:32 -070031 return createTestInstance(Collections.emptyList());
32 }
33
Steve McKay4f78ba62016-10-04 16:48:49 -070034 public static SelectionManager createTestInstance(List<String> docs) {
35 return createTestInstance(docs, SelectionManager.MODE_MULTIPLE);
Garfield Tan84bd0f12016-09-12 14:18:32 -070036 }
37
Steve McKay4f78ba62016-10-04 16:48:49 -070038 public static SelectionManager createTestInstance(
Garfield Tan84bd0f12016-09-12 14:18:32 -070039 List<String> docs, @SelectionMode int mode) {
40 return createTestInstance(
41 docs,
42 mode,
43 (String id, boolean nextState) -> true);
44 }
45
Steve McKay4f78ba62016-10-04 16:48:49 -070046 public static SelectionManager createTestInstance(
Garfield Tan84bd0f12016-09-12 14:18:32 -070047 List<String> docs, @SelectionMode int mode, SelectionPredicate canSetState) {
48 TestDocumentsAdapter adapter = new TestDocumentsAdapter(docs);
Steve McKay4f78ba62016-10-04 16:48:49 -070049 SelectionManager manager = new SelectionManager(mode);
50 manager.reset(adapter, canSetState);
Garfield Tan84bd0f12016-09-12 14:18:32 -070051
52 return manager;
53 }
54}