Garfield Tan | 84bd0f1 | 2016-09-12 14:18:32 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.documentsui.testing; |
| 18 | |
Garfield Tan | 84bd0f1 | 2016-09-12 14:18:32 -0700 | [diff] [blame] | 19 | import com.android.documentsui.dirlist.TestDocumentsAdapter; |
Steve McKay | 4f78ba6 | 2016-10-04 16:48:49 -0700 | [diff] [blame^] | 20 | import com.android.documentsui.selection.SelectionManager; |
| 21 | import com.android.documentsui.selection.SelectionManager.SelectionMode; |
| 22 | import com.android.documentsui.selection.SelectionManager.SelectionPredicate; |
Garfield Tan | 84bd0f1 | 2016-09-12 14:18:32 -0700 | [diff] [blame] | 23 | |
| 24 | import java.util.Collections; |
| 25 | import java.util.List; |
| 26 | |
| 27 | public class MultiSelectManagers { |
| 28 | private MultiSelectManagers() {} |
| 29 | |
Steve McKay | 4f78ba6 | 2016-10-04 16:48:49 -0700 | [diff] [blame^] | 30 | public static SelectionManager createTestInstance() { |
Garfield Tan | 84bd0f1 | 2016-09-12 14:18:32 -0700 | [diff] [blame] | 31 | return createTestInstance(Collections.emptyList()); |
| 32 | } |
| 33 | |
Steve McKay | 4f78ba6 | 2016-10-04 16:48:49 -0700 | [diff] [blame^] | 34 | public static SelectionManager createTestInstance(List<String> docs) { |
| 35 | return createTestInstance(docs, SelectionManager.MODE_MULTIPLE); |
Garfield Tan | 84bd0f1 | 2016-09-12 14:18:32 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Steve McKay | 4f78ba6 | 2016-10-04 16:48:49 -0700 | [diff] [blame^] | 38 | public static SelectionManager createTestInstance( |
Garfield Tan | 84bd0f1 | 2016-09-12 14:18:32 -0700 | [diff] [blame] | 39 | List<String> docs, @SelectionMode int mode) { |
| 40 | return createTestInstance( |
| 41 | docs, |
| 42 | mode, |
| 43 | (String id, boolean nextState) -> true); |
| 44 | } |
| 45 | |
Steve McKay | 4f78ba6 | 2016-10-04 16:48:49 -0700 | [diff] [blame^] | 46 | public static SelectionManager createTestInstance( |
Garfield Tan | 84bd0f1 | 2016-09-12 14:18:32 -0700 | [diff] [blame] | 47 | List<String> docs, @SelectionMode int mode, SelectionPredicate canSetState) { |
| 48 | TestDocumentsAdapter adapter = new TestDocumentsAdapter(docs); |
Steve McKay | 4f78ba6 | 2016-10-04 16:48:49 -0700 | [diff] [blame^] | 49 | SelectionManager manager = new SelectionManager(mode); |
| 50 | manager.reset(adapter, canSetState); |
Garfield Tan | 84bd0f1 | 2016-09-12 14:18:32 -0700 | [diff] [blame] | 51 | |
| 52 | return manager; |
| 53 | } |
| 54 | } |