blob: 3b550e61c1fd426b977b9d80db284d7d38930578 [file] [log] [blame]
Garfield Tan7d75f7b2016-09-20 16:33:24 -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.sidebar;
18
19import android.annotation.LayoutRes;
Ben Lin174fc2e2017-03-01 17:53:20 -080020import android.view.DragEvent;
Garfield Tan7d75f7b2016-09-20 16:33:24 -070021import android.view.LayoutInflater;
22import android.view.Menu;
23import android.view.MenuInflater;
24import android.view.View;
25import android.view.ViewGroup;
26
27import com.android.documentsui.MenuManager;
28import 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 */
34abstract 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 Lin174fc2e2017-03-01 17:53:20 -080061 boolean dropOn(DragEvent event) {
Garfield Tan7d75f7b2016-09-20 16:33:24 -070062 return false;
63 }
64
Garfield Tanb285b402016-09-21 17:12:18 -070065 boolean showAppDetails() {
Garfield Tan7d75f7b2016-09-20 16:33:24 -070066 return false;
67 }
68
69 void createContextMenu(Menu menu, MenuInflater inflater, MenuManager menuManager) {}
70}