f29ebc097bab8b8d1248f6515d302e90fd782bbd
1 /* ownCloud Android client application
2 * Copyright (C) 2011 Bartek Przybylski
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.
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.
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/>.
18 package eu
.alefzero
.owncloud
.ui
.adapter
;
20 import java
.util
.Vector
;
22 import eu
.alefzero
.owncloud
.DisplayUtils
;
23 import eu
.alefzero
.owncloud
.R
;
24 import eu
.alefzero
.owncloud
.datamodel
.OCFile
;
25 import eu
.alefzero
.owncloud
.db
.ProviderMeta
;
26 import eu
.alefzero
.owncloud
.db
.ProviderMeta
.ProviderTableMeta
;
28 import android
.content
.Context
;
29 import android
.database
.Cursor
;
30 import android
.database
.DataSetObserver
;
31 import android
.util
.Log
;
32 import android
.view
.LayoutInflater
;
33 import android
.view
.View
;
34 import android
.view
.ViewGroup
;
35 import android
.widget
.ImageView
;
36 import android
.widget
.ListAdapter
;
37 import android
.widget
.TextView
;
40 * This Adapter populates a ListView with all files and
41 * folders in an ownCloud instance.
42 * @author Bartek Przybylski
45 public class FileListListAdapter
implements ListAdapter
{
46 private Context mContext
;
48 private Vector
<OCFile
> mFiles
;
50 public FileListListAdapter(OCFile f
, Context context
) {
52 mFiles
= mFile
.getDirectoryContent();
56 public boolean areAllItemsEnabled() {
60 public boolean isEnabled(int position
) {
61 // TODO Auto-generated method stub
65 public int getCount() {
66 // TODO Auto-generated method stub
70 public Object
getItem(int position
) {
71 if (mFiles
.size() <= position
)
73 return mFiles
.get(position
);
76 public long getItemId(int position
) {
77 // TODO Auto-generated method stub
81 public int getItemViewType(int position
) {
82 // TODO Auto-generated method stub
86 public View
getView(int position
, View convertView
, ViewGroup parent
) {
89 LayoutInflater vi
= (LayoutInflater
) mContext
.getSystemService(Context
.LAYOUT_INFLATER_SERVICE
);
90 v
= vi
.inflate(R
.layout
.list_layout
, null
);
92 if (mFiles
.size() > position
) {
93 OCFile f
= mFiles
.get(position
);
94 TextView tv
= (TextView
) v
.findViewById(R
.id
.Filename
);
95 tv
.setText(DisplayUtils
.HtmlDecode(f
.getFileName()));
96 if (!f
.getMimetype().equals("DIR")) {
97 ImageView iv
= (ImageView
) v
.findViewById(R
.id
.imageView1
);
98 iv
.setImageResource(R
.drawable
.file
);
105 public int getViewTypeCount() {
106 // TODO Auto-generated method stub
110 public boolean hasStableIds() {
111 // TODO Auto-generated method stub
115 public boolean isEmpty() {
116 // TODO Auto-generated method stub
120 public void registerDataSetObserver(DataSetObserver observer
) {
121 // TODO Auto-generated method stub
125 public void unregisterDataSetObserver(DataSetObserver observer
) {
126 // TODO Auto-generated method stub