ab69f075850be87be2165b074e520b95105253ff
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
.security
.Provider
;
22 import eu
.alefzero
.owncloud
.DisplayUtils
;
23 import eu
.alefzero
.owncloud
.R
;
24 import eu
.alefzero
.owncloud
.R
.drawable
;
25 import eu
.alefzero
.owncloud
.R
.id
;
26 import eu
.alefzero
.owncloud
.R
.layout
;
27 import eu
.alefzero
.owncloud
.db
.ProviderMeta
;
28 import eu
.alefzero
.owncloud
.db
.ProviderMeta
.ProviderTableMeta
;
30 import android
.content
.Context
;
31 import android
.database
.Cursor
;
32 import android
.database
.DataSetObserver
;
33 import android
.util
.Log
;
34 import android
.view
.LayoutInflater
;
35 import android
.view
.View
;
36 import android
.view
.ViewGroup
;
37 import android
.view
.View
.OnLongClickListener
;
38 import android
.widget
.AdapterView
;
39 import android
.widget
.ImageView
;
40 import android
.widget
.ListAdapter
;
41 import android
.widget
.TextView
;
42 import android
.widget
.AdapterView
.OnItemClickListener
;
45 * This Adapter populates a ListView with all files and
46 * folders in an ownCloud instance.
47 * @author Bartek Przybylski
50 public class FileListListAdapter
implements ListAdapter
{
52 private Cursor mCursor
;
53 private Context mContext
;
55 public FileListListAdapter(Cursor c
, Context context
) {
60 public boolean areAllItemsEnabled() {
64 public boolean isEnabled(int position
) {
65 // TODO Auto-generated method stub
69 public int getCount() {
70 // TODO Auto-generated method stub
71 return mCursor
.getCount();
74 public Object
getItem(int position
) {
75 // TODO Auto-generated method stub
79 public long getItemId(int position
) {
80 // TODO Auto-generated method stub
84 public int getItemViewType(int position
) {
85 // TODO Auto-generated method stub
89 public View
getView(int position
, View convertView
, ViewGroup parent
) {
92 LayoutInflater vi
= (LayoutInflater
) mContext
.getSystemService(Context
.LAYOUT_INFLATER_SERVICE
);
93 v
= vi
.inflate(R
.layout
.list_layout
, null
);
95 if (mCursor
.moveToPosition(position
)) {
96 TextView tv
= (TextView
) v
.findViewById(R
.id
.Filename
);
97 tv
.setText(DisplayUtils
.HtmlDecode(mCursor
.getString(mCursor
.getColumnIndex(ProviderMeta
.ProviderTableMeta
.FILE_NAME
))));
98 if (!mCursor
.getString(mCursor
.getColumnIndex(ProviderTableMeta
.FILE_CONTENT_TYPE
)).equals("DIR")) {
99 ImageView iv
= (ImageView
) v
.findViewById(R
.id
.imageView1
);
100 iv
.setImageResource(R
.drawable
.file
);
107 public int getViewTypeCount() {
108 // TODO Auto-generated method stub
112 public boolean hasStableIds() {
113 // TODO Auto-generated method stub
117 public boolean isEmpty() {
118 // TODO Auto-generated method stub
122 public void registerDataSetObserver(DataSetObserver observer
) {
123 // TODO Auto-generated method stub
127 public void unregisterDataSetObserver(DataSetObserver observer
) {
128 // TODO Auto-generated method stub