2b912ee8e06b8165874052972ad35e1721f02ef2
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
;
26 import android
.content
.Context
;
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
;
36 * This Adapter populates a ListView with all files and
37 * folders in an ownCloud instance.
38 * @author Bartek Przybylski
41 public class FileListListAdapter
implements ListAdapter
{
42 private Context mContext
;
44 private Vector
<OCFile
> mFiles
;
46 public FileListListAdapter(OCFile f
, Context context
) {
48 mFiles
= mFile
.getDirectoryContent();
52 public boolean areAllItemsEnabled() {
56 public boolean isEnabled(int position
) {
57 // TODO Auto-generated method stub
61 public int getCount() {
62 // TODO Auto-generated method stub
63 return mFiles
!= null ? mFiles
.size() : 0;
66 public Object
getItem(int position
) {
67 if (mFiles
.size() <= position
)
69 return mFiles
.get(position
);
72 public long getItemId(int position
) {
73 // TODO Auto-generated method stub
77 public int getItemViewType(int position
) {
78 // TODO Auto-generated method stub
82 public View
getView(int position
, View convertView
, ViewGroup parent
) {
85 LayoutInflater vi
= (LayoutInflater
) mContext
.getSystemService(Context
.LAYOUT_INFLATER_SERVICE
);
86 v
= vi
.inflate(R
.layout
.list_layout
, null
);
88 if (mFiles
.size() > position
) {
89 OCFile f
= mFiles
.get(position
);
90 TextView tv
= (TextView
) v
.findViewById(R
.id
.Filename
);
91 tv
.setText(DisplayUtils
.HtmlDecode(f
.getFileName()));
92 if (!f
.getMimetype().equals("DIR")) {
93 ImageView iv
= (ImageView
) v
.findViewById(R
.id
.imageView1
);
94 iv
.setImageResource(R
.drawable
.file
);
101 public int getViewTypeCount() {
102 // TODO Auto-generated method stub
106 public boolean hasStableIds() {
107 // TODO Auto-generated method stub
111 public boolean isEmpty() {
112 // TODO Auto-generated method stub
116 public void registerDataSetObserver(DataSetObserver observer
) {
117 // TODO Auto-generated method stub
121 public void unregisterDataSetObserver(DataSetObserver observer
) {
122 // TODO Auto-generated method stub