}
+ public Cursor getContent(long parentId) {
+ Uri req_uri = Uri.withAppendedPath(
+ ProviderTableMeta.CONTENT_URI_DIR,
+ String.valueOf(parentId));
+ Cursor c = null;
+
+ if (getContentProviderClient() != null) {
+ try {
+ c = getContentProviderClient().query(req_uri, null,
+ ProviderTableMeta.FILE_PARENT + "=?" ,
+ new String[] { String.valueOf(parentId)}, null);
+ } catch (RemoteException e) {
+ Log_OC.e(TAG, e.getMessage());
+ return c;
+ }
+ } else {
+ c = getContentResolver().query(req_uri, null,
+ ProviderTableMeta.FILE_PARENT + "=?" ,
+ new String[] { String.valueOf(parentId)}, null);
+ }
+
+ return c;
+ }
+
private OCFile createRootDir() {
OCFile file = new OCFile(OCFile.ROOT_PATH);
file.setMimetype("DIR");
return c;
}
- private Cursor getShareCursorForValue(String key, String value) {
- Cursor c = null;
- if (getContentResolver() != null) {
- c = getContentResolver()
- .query(ProviderTableMeta.CONTENT_URI_SHARE,
- null,
- key + "=? AND "
- + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER
- + "=?",
- new String[] { value, mAccount.name }, null);
- } else {
- try {
- c = getContentProviderClient().query(
- ProviderTableMeta.CONTENT_URI_SHARE,
- null,
- key + "=? AND " + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER
- + "=?", new String[] { value, mAccount.name },
- null);
- } catch (RemoteException e) {
- Log_OC.e(TAG, "Could not get file details: " + e.getMessage());
- c = null;
- }
- }
- return c;
- }
+// private Cursor getShareCursorForValue(String key, String value) {
+// Cursor c = null;
+// if (getContentResolver() != null) {
+// c = getContentResolver()
+// .query(ProviderTableMeta.CONTENT_URI_SHARE,
+// null,
+// key + "=? AND "
+// + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER
+// + "=?",
+// new String[] { value, mAccount.name }, null);
+// } else {
+// try {
+// c = getContentProviderClient().query(
+// ProviderTableMeta.CONTENT_URI_SHARE,
+// null,
+// key + "=? AND " + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER
+// + "=?", new String[] { value, mAccount.name },
+// null);
+// } catch (RemoteException e) {
+// Log_OC.e(TAG, "Could not get file details: " + e.getMessage());
+// c = null;
+// }
+// }
+// return c;
+// }
private OCFile createFileInstance(Cursor c) {
OCFile file = null;
return overriden;
}
- private OCShare getShareById(long id) {
- Cursor c = getShareCursorForValue(ProviderTableMeta._ID, String.valueOf(id));
- OCShare share = null;
- if (c.moveToFirst()) {
- share = createShareInstance(c);
- }
- c.close();
- return share;
- }
-
- private OCShare getShareByRemoteId(long remoteId) {
- Cursor c = getShareCursorForValue(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, String.valueOf(remoteId));
- OCShare share = null;
- if (c.moveToFirst()) {
- share = createShareInstance(c);
- }
- c.close();
- return share;
- }
+// private OCShare getShareById(long id) {
+// Cursor c = getShareCursorForValue(ProviderTableMeta._ID, String.valueOf(id));
+// OCShare share = null;
+// if (c.moveToFirst()) {
+// share = createShareInstance(c);
+// }
+// c.close();
+// return share;
+// }
+//
+// private OCShare getShareByRemoteId(long remoteId) {
+// Cursor c = getShareCursorForValue(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, String.valueOf(remoteId));
+// OCShare share = null;
+// if (c.moveToFirst()) {
+// share = createShareInstance(c);
+// }
+// c.close();
+// return share;
+// }
public OCShare getFirstShareByPathAndType(String path, ShareType type) {
Cursor c = null;
\r
import android.accounts.Account;\r
import android.content.Context;\r
+import android.database.Cursor;\r
+import android.support.v4.widget.SimpleCursorAdapter;\r
import android.view.LayoutInflater;\r
import android.view.View;\r
import android.view.ViewGroup;\r
-import android.widget.BaseAdapter;\r
+//import android.widget.BaseAdapter;\r
import android.widget.ImageView;\r
import android.widget.ListAdapter;\r
import android.widget.ListView;\r
import com.owncloud.android.authentication.AccountUtils;\r
import com.owncloud.android.datamodel.FileDataStorageManager;\r
import com.owncloud.android.datamodel.OCFile;\r
+import com.owncloud.android.db.ProviderMeta;\r
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;\r
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;\r
import com.owncloud.android.ui.activity.TransferServiceGetter;\r
* @author Bartek Przybylski\r
* \r
*/\r
-public class FileListListAdapter extends BaseAdapter implements ListAdapter {\r
+public class FileListListAdapter extends SimpleCursorAdapter /*BaseAdapter*/ implements ListAdapter {\r
+\r
private Context mContext;\r
- private OCFile mFile = null;\r
+ private static OCFile mFile = null;\r
private Vector<OCFile> mFiles = null;\r
- private FileDataStorageManager mStorageManager;\r
+ private static FileDataStorageManager mStorageManager;\r
private Account mAccount;\r
private TransferServiceGetter mTransferServiceGetter;\r
+ private static String[] cursorFrom = { ProviderMeta.ProviderTableMeta.FILE_NAME,\r
+ ProviderMeta.ProviderTableMeta.FILE_MODIFIED, \r
+ ProviderMeta.ProviderTableMeta.FILE_CONTENT_LENGTH\r
+ }; \r
+ private static int[] cursorTo = { R.id.Filename, \r
+ R.id.last_mod, \r
+ R.id.file_size\r
+ };\r
+\r
+ public FileListListAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {\r
+ super(context, layout, c, from, to, flags);\r
+ // TODO Auto-generated constructor stub\r
+ }\r
\r
- public FileListListAdapter(Context context, TransferServiceGetter transferServiceGetter) {\r
+ public FileListListAdapter(Context context, TransferServiceGetter transferServiceGetter, OCFile file) {\r
+ super(context,\r
+ R.layout.list_item, \r
+ file == null ? null : mStorageManager.getContent(file.getParentId()),\r
+ cursorFrom,\r
+ cursorTo, \r
+ 0);\r
mContext = context;\r
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);\r
mTransferServiceGetter = transferServiceGetter;\r
+ mFile = file;\r
}\r
\r
@Override\r