• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 
17 package com.android.documentsui.dirlist;
18 
19 import android.view.MotionEvent;
20 
21 import androidx.recyclerview.selection.ItemDetailsLookup.ItemDetails;
22 
23 /**
24  * Provide information of a specific RecyclerView item for selection.
25  */
26 public final class DocumentItemDetails extends ItemDetails<String> {
27     private final DocumentHolder mDocumentHolder;
28 
DocumentItemDetails(DocumentHolder holder)29     DocumentItemDetails(DocumentHolder holder) {
30         mDocumentHolder = holder;
31     }
32 
33     /**
34      * @return The view type of this ViewHolder.
35      */
getItemViewType()36     public int getItemViewType() {
37         return mDocumentHolder.getItemViewType();
38     }
39 
40     @Override
getPosition()41     public int getPosition() {
42         return mDocumentHolder.getAdapterPosition();
43     }
44 
45     @Override
getSelectionKey()46     public String getSelectionKey() {
47         return mDocumentHolder.getModelId();
48     }
49 
50     @Override
inDragRegion(MotionEvent e)51     public boolean inDragRegion(MotionEvent e) {
52         return mDocumentHolder.inDragRegion(e);
53     }
54 
55     @Override
inSelectionHotspot(MotionEvent e)56     public boolean inSelectionHotspot(MotionEvent e) {
57         return mDocumentHolder.inSelectRegion(e);
58     }
59 
inPreviewIconHotspot(MotionEvent e)60     public boolean inPreviewIconHotspot(MotionEvent e) {
61         return mDocumentHolder.inPreviewIconRegion(e);
62     }
63 }
64