20039eef7fb47fa3149e6e6d05064d63c08c8d94
[pub/Android/ownCloud.git] / src / com / owncloud / android / datamodel / FileListCursorLoader.java
1 /* ownCloud Android client application
2 * Copyright (C) 2012-2014 ownCloud Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18 package com.owncloud.android.datamodel;
19
20 import com.owncloud.android.utils.Log_OC;
21
22 import android.content.Context;
23 import android.database.Cursor;
24 import android.net.Uri;
25 import android.support.v4.content.CursorLoader;
26
27 /**
28 * CursorLoader for FileList
29 *
30 * @author masensio
31 *
32 */
33 public class FileListCursorLoader extends CursorLoader {
34
35 private static final String TAG = CursorLoader.class.getSimpleName();
36
37 private long mParentId;
38 private FileDataStorageManager mStorageManager;
39
40 public FileListCursorLoader(Context context) {
41 super(context);
42 // TODO Auto-generated constructor stub
43 }
44
45 public FileListCursorLoader(Context context, Uri uri, String[] projection, String selection,
46 String[] selectionArgs, String sortOrder) {
47 super(context, uri, projection, selection, selectionArgs, sortOrder);
48 // TODO Auto-generated constructor stub
49 }
50
51 public FileListCursorLoader(Context context, FileDataStorageManager storageManager) {
52 super(context);
53 mStorageManager = storageManager;
54 }
55
56 public void setParentId(long parentId) {
57 mParentId = parentId;
58 }
59 public long getParentId(){
60 return mParentId;
61 }
62
63 public void setStorageManager(FileDataStorageManager storageManager) {
64 mStorageManager = storageManager;
65 }
66
67 @Override
68 public Cursor loadInBackground() {
69 Log_OC.d(TAG, "loadInBackgroud");
70 Cursor cursor = null;
71 if (mStorageManager != null) {
72 cursor = mStorageManager.getContent(mParentId);
73 }
74 return cursor;
75 }
76 }