OC-2982: Update Settings
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / fragment / FileFragment.java
1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 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.ui.fragment;
19
20 import android.support.v4.app.Fragment;
21
22 import com.actionbarsherlock.app.SherlockFragment;
23 import com.owncloud.android.datamodel.OCFile;
24 import com.owncloud.android.ui.activity.TransferServiceGetter;
25
26
27 /**
28 * Common methods for {@link Fragment}s containing {@link OCFile}s
29 *
30 * @author David A. Velasco
31 *
32 */
33 public class FileFragment extends SherlockFragment {
34
35 private OCFile mFile;
36
37
38 /**
39 * Creates an empty fragment.
40 *
41 * It's necessary to keep a public constructor without parameters; the system uses it when tries to reinstantiate a fragment automatically.
42 */
43 public FileFragment() {
44 mFile = null;
45 }
46
47 /**
48 * Creates an instance for a given {@OCFile}.
49 *
50 * @param file
51 */
52 public FileFragment(OCFile file) {
53 mFile = file;
54 }
55
56 /**
57 * Getter for the hold {@link OCFile}
58 *
59 * @return The {@link OCFile} hold
60 */
61 public OCFile getFile() {
62 return mFile;
63 }
64
65
66 protected void setFile(OCFile file) {
67 mFile = file;
68 }
69
70 /**
71 * Interface to implement by any Activity that includes some instance of FileFragment
72 *
73 * @author David A. Velasco
74 */
75 public interface ContainerActivity extends TransferServiceGetter {
76
77 /**
78 * Callback method invoked when the detail fragment wants to notice its container
79 * activity about a relevant state the file shown by the fragment.
80 *
81 * Added to notify to FileDisplayActivity about the need of refresh the files list.
82 *
83 * Currently called when:
84 * - a download is started;
85 * - a rename is completed;
86 * - a deletion is completed;
87 * - the 'inSync' flag is changed;
88 */
89 public void onFileStateChanged();
90
91 /**
92 * Request the parent activity to show the details of an {@link OCFile}.
93 *
94 * @param file File to show details
95 */
96 public void showDetails(OCFile file);
97
98 }
99
100 }