Garfield Tan | 7d75f7b | 2016-09-20 16:33:24 -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.sidebar; |
| 18 | |
| 19 | import android.annotation.LayoutRes; |
Ben Lin | 174fc2e | 2017-03-01 17:53:20 -0800 | [diff] [blame] | 20 | import android.view.DragEvent; |
Garfield Tan | 7d75f7b | 2016-09-20 16:33:24 -0700 | [diff] [blame] | 21 | import android.view.LayoutInflater; |
| 22 | import android.view.Menu; |
| 23 | import android.view.MenuInflater; |
| 24 | import android.view.View; |
| 25 | import android.view.ViewGroup; |
| 26 | |
| 27 | import com.android.documentsui.MenuManager; |
| 28 | import com.android.documentsui.R; |
| 29 | |
| 30 | /** |
| 31 | * Describes a root navigation point of documents. Each one of them is presented as an item in the |
| 32 | * sidebar |
| 33 | */ |
| 34 | abstract class Item { |
| 35 | private final @LayoutRes int mLayoutId; |
| 36 | |
| 37 | final String stringId; |
| 38 | |
| 39 | public Item(@LayoutRes int layoutId, String stringId) { |
| 40 | mLayoutId = layoutId; |
| 41 | this.stringId = stringId; |
| 42 | } |
| 43 | |
| 44 | public View getView(View convertView, ViewGroup parent) { |
| 45 | if (convertView == null |
| 46 | || (Integer) convertView.getTag(R.id.layout_id_tag) != mLayoutId) { |
| 47 | convertView = LayoutInflater.from(parent.getContext()) |
| 48 | .inflate(mLayoutId, parent, false); |
| 49 | } |
| 50 | convertView.setTag(R.id.layout_id_tag, mLayoutId); |
| 51 | bindView(convertView); |
| 52 | return convertView; |
| 53 | } |
| 54 | |
| 55 | abstract void bindView(View convertView); |
| 56 | |
| 57 | abstract boolean isDropTarget(); |
| 58 | |
| 59 | abstract void open(); |
| 60 | |
Ben Lin | 174fc2e | 2017-03-01 17:53:20 -0800 | [diff] [blame] | 61 | boolean dropOn(DragEvent event) { |
Garfield Tan | 7d75f7b | 2016-09-20 16:33:24 -0700 | [diff] [blame] | 62 | return false; |
| 63 | } |
| 64 | |
Garfield Tan | b285b40 | 2016-09-21 17:12:18 -0700 | [diff] [blame] | 65 | boolean showAppDetails() { |
Garfield Tan | 7d75f7b | 2016-09-20 16:33:24 -0700 | [diff] [blame] | 66 | return false; |
| 67 | } |
| 68 | |
| 69 | void createContextMenu(Menu menu, MenuInflater inflater, MenuManager menuManager) {} |
| 70 | } |