6bb8c1067849c4c8e858de92fca2a31c098f7b33
[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 eu.alefzero.owncloud.DisplayUtils;
21 import eu.alefzero.owncloud.R;
22 import eu.alefzero.owncloud.db.ProviderMeta;
23 import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
24
25 import android.content.Context;
26 import android.database.Cursor;
27 import android.database.DataSetObserver;
28 import android.view.LayoutInflater;
29 import android.view.View;
30 import android.view.ViewGroup;
31 import android.widget.ImageView;
32 import android.widget.ListAdapter;
33 import android.widget.TextView;
34
35 /**
36 * This Adapter populates a ListView with all files and
37 * folders in an ownCloud instance.
38 * @author Bartek Przybylski
39 *
40 */
41 public class FileListListAdapter implements ListAdapter {
42
43 private Cursor mCursor;
44 private Context mContext;
45
46 public FileListListAdapter(Cursor c, Context context) {
47 mCursor = c;
48 mContext = context;
49 }
50
51 public boolean areAllItemsEnabled() {
52 return true;
53 }
54
55 public boolean isEnabled(int position) {
56 // TODO Auto-generated method stub
57 return true;
58 }
59
60 public int getCount() {
61 // TODO Auto-generated method stub
62 return mCursor.getCount();
63 }
64
65 public Object getItem(int position) {
66 // TODO Auto-generated method stub
67 return null;
68 }
69
70 public long getItemId(int position) {
71 // TODO Auto-generated method stub
72 return 0;
73 }
74
75 public int getItemViewType(int position) {
76 // TODO Auto-generated method stub
77 return 0;
78 }
79
80 public View getView(int position, View convertView, ViewGroup parent) {
81 View v = convertView;
82 if (v == null) {
83 LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
84 v = vi.inflate(R.layout.list_layout, null);
85 }
86 if (mCursor.moveToPosition(position)) {
87 TextView tv = (TextView) v.findViewById(R.id.Filename);
88 tv.setText(DisplayUtils.HtmlDecode(mCursor.getString(mCursor.getColumnIndex(ProviderMeta.ProviderTableMeta.FILE_NAME))));
89 if (!mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)).equals("DIR")) {
90 ImageView iv = (ImageView) v.findViewById(R.id.imageView1);
91 iv.setImageResource(R.drawable.file);
92 }
93 }
94
95 return v;
96 }
97
98 public int getViewTypeCount() {
99 // TODO Auto-generated method stub
100 return 4;
101 }
102
103 public boolean hasStableIds() {
104 // TODO Auto-generated method stub
105 return true;
106 }
107
108 public boolean isEmpty() {
109 // TODO Auto-generated method stub
110 return false;
111 }
112
113 public void registerDataSetObserver(DataSetObserver observer) {
114 // TODO Auto-generated method stub
115
116 }
117
118 public void unregisterDataSetObserver(DataSetObserver observer) {
119 // TODO Auto-generated method stub
120
121 }
122 }