fa72803d5574ff635a78c25bed56161cfc36b1a4
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 file
, Context context
) {
48 mFiles
= mFile
.getDirectoryContent();
53 public boolean areAllItemsEnabled() {
58 public boolean isEnabled(int position
) {
59 // TODO Auto-generated method stub
64 public int getCount() {
65 return mFiles
!= null ? mFiles
.size() : 0;
69 public Object
getItem(int position
) {
70 if (mFiles
.size() <= position
)
72 return mFiles
.get(position
);
76 public long getItemId(int position
) {
77 return mFiles
!= null ? mFiles
.get(position
).getFileId() : 0;
81 public int getItemViewType(int position
) {
82 // TODO Auto-generated method stub
87 public View
getView(int position
, View convertView
, ViewGroup parent
) {
88 View view
= convertView
;
90 LayoutInflater inflator
= (LayoutInflater
) mContext
.getSystemService(Context
.LAYOUT_INFLATER_SERVICE
);
91 view
= inflator
.inflate(R
.layout
.list_layout
, null
);
93 if (mFiles
.size() > position
) {
94 OCFile file
= mFiles
.get(position
);
95 TextView fileName
= (TextView
) view
.findViewById(R
.id
.Filename
);
96 fileName
.setText(DisplayUtils
.HtmlDecode(file
.getFileName()));
97 if (!file
.getMimetype().equals("DIR")) {
98 ImageView fileIcon
= (ImageView
) view
.findViewById(R
.id
.imageView1
);
99 fileIcon
.setImageResource(R
.drawable
.file
);
107 public int getViewTypeCount() {
112 public boolean hasStableIds() {
117 public boolean isEmpty() {
118 return mFiles
!= null ? mFiles
.isEmpty() : false
;
122 public void registerDataSetObserver(DataSetObserver observer
) {
123 // TODO Auto-generated method stub
128 public void unregisterDataSetObserver(DataSetObserver observer
) {
129 // TODO Auto-generated method stub