ab69f075850be87be2165b074e520b95105253ff
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / ui / adapter / FileListListAdapter.java
1 /* ownCloud Android client application
2 * Copyright (C) 2011 Bartek Przybylski
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18 package eu.alefzero.owncloud.ui.adapter;
19
20 import java.security.Provider;
21
22 import eu.alefzero.owncloud.DisplayUtils;
23 import eu.alefzero.owncloud.R;
24 import eu.alefzero.owncloud.R.drawable;
25 import eu.alefzero.owncloud.R.id;
26 import eu.alefzero.owncloud.R.layout;
27 import eu.alefzero.owncloud.db.ProviderMeta;
28 import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
29
30 import android.content.Context;
31 import android.database.Cursor;
32 import android.database.DataSetObserver;
33 import android.util.Log;
34 import android.view.LayoutInflater;
35 import android.view.View;
36 import android.view.ViewGroup;
37 import android.view.View.OnLongClickListener;
38 import android.widget.AdapterView;
39 import android.widget.ImageView;
40 import android.widget.ListAdapter;
41 import android.widget.TextView;
42 import android.widget.AdapterView.OnItemClickListener;
43
44 /**
45 * This Adapter populates a ListView with all files and
46 * folders in an ownCloud instance.
47 * @author Bartek Przybylski
48 *
49 */
50 public class FileListListAdapter implements ListAdapter {
51
52 private Cursor mCursor;
53 private Context mContext;
54
55 public FileListListAdapter(Cursor c, Context context) {
56 mCursor = c;
57 mContext = context;
58 }
59
60 public boolean areAllItemsEnabled() {
61 return true;
62 }
63
64 public boolean isEnabled(int position) {
65 // TODO Auto-generated method stub
66 return true;
67 }
68
69 public int getCount() {
70 // TODO Auto-generated method stub
71 return mCursor.getCount();
72 }
73
74 public Object getItem(int position) {
75 // TODO Auto-generated method stub
76 return null;
77 }
78
79 public long getItemId(int position) {
80 // TODO Auto-generated method stub
81 return 0;
82 }
83
84 public int getItemViewType(int position) {
85 // TODO Auto-generated method stub
86 return 0;
87 }
88
89 public View getView(int position, View convertView, ViewGroup parent) {
90 View v = convertView;
91 if (v == null) {
92 LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
93 v = vi.inflate(R.layout.list_layout, null);
94 }
95 if (mCursor.moveToPosition(position)) {
96 TextView tv = (TextView) v.findViewById(R.id.Filename);
97 tv.setText(DisplayUtils.HtmlDecode(mCursor.getString(mCursor.getColumnIndex(ProviderMeta.ProviderTableMeta.FILE_NAME))));
98 if (!mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)).equals("DIR")) {
99 ImageView iv = (ImageView) v.findViewById(R.id.imageView1);
100 iv.setImageResource(R.drawable.file);
101 }
102 }
103
104 return v;
105 }
106
107 public int getViewTypeCount() {
108 // TODO Auto-generated method stub
109 return 4;
110 }
111
112 public boolean hasStableIds() {
113 // TODO Auto-generated method stub
114 return true;
115 }
116
117 public boolean isEmpty() {
118 // TODO Auto-generated method stub
119 return false;
120 }
121
122 public void registerDataSetObserver(DataSetObserver observer) {
123 // TODO Auto-generated method stub
124
125 }
126
127 public void unregisterDataSetObserver(DataSetObserver observer) {
128 // TODO Auto-generated method stub
129
130 }
131 }