6bb8c1067849c4c8e858de92fca2a31c098f7b33
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 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
;
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
;
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
{
43 private Cursor mCursor
;
44 private Context mContext
;
46 public FileListListAdapter(Cursor c
, Context context
) {
51 public boolean areAllItemsEnabled() {
55 public boolean isEnabled(int position
) {
56 // TODO Auto-generated method stub
60 public int getCount() {
61 // TODO Auto-generated method stub
62 return mCursor
.getCount();
65 public Object
getItem(int position
) {
66 // TODO Auto-generated method stub
70 public long getItemId(int position
) {
71 // TODO Auto-generated method stub
75 public int getItemViewType(int position
) {
76 // TODO Auto-generated method stub
80 public View
getView(int position
, View convertView
, ViewGroup parent
) {
83 LayoutInflater vi
= (LayoutInflater
) mContext
.getSystemService(Context
.LAYOUT_INFLATER_SERVICE
);
84 v
= vi
.inflate(R
.layout
.list_layout
, null
);
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
);
98 public int getViewTypeCount() {
99 // TODO Auto-generated method stub
103 public boolean hasStableIds() {
104 // TODO Auto-generated method stub
108 public boolean isEmpty() {
109 // TODO Auto-generated method stub
113 public void registerDataSetObserver(DataSetObserver observer
) {
114 // TODO Auto-generated method stub
118 public void unregisterDataSetObserver(DataSetObserver observer
) {
119 // TODO Auto-generated method stub