2 * ownCloud Android client application
4 * @author David A. Velasco
5 * Copyright (C) 2015 ownCloud Inc.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2,
9 * as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 package com
.owncloud
.android
.ui
.fragment
;
23 import android
.accounts
.Account
;
24 import android
.app
.Activity
;
25 import android
.support
.v4
.app
.Fragment
;
27 import com
.owncloud
.android
.datamodel
.OCFile
;
28 import com
.owncloud
.android
.files
.services
.FileDownloader
.FileDownloaderBinder
;
29 import com
.owncloud
.android
.files
.services
.FileUploader
.FileUploaderBinder
;
30 import com
.owncloud
.android
.ui
.activity
.ComponentsGetter
;
34 * Common methods for {@link Fragment}s containing {@link OCFile}s
36 public class FileFragment
extends Fragment
{
40 protected ContainerActivity mContainerActivity
;
44 * Creates an empty fragment.
46 * It's necessary to keep a public constructor without parameters; the system uses it when
47 * tries to reinstantiate a fragment automatically.
49 public FileFragment() {
54 * Creates an instance for a given {@OCFile}.
58 public FileFragment(OCFile file
) {
63 * Getter for the hold {@link OCFile}
65 * @return The {@link OCFile} hold
67 public OCFile
getFile() {
72 protected void setFile(OCFile file
) {
81 public void onAttach(Activity activity
) {
82 super.onAttach(activity
);
84 mContainerActivity
= (ContainerActivity
) activity
;
86 } catch (ClassCastException e
) {
87 throw new ClassCastException(activity
.toString() + " must implement " +
88 ContainerActivity
.class.getSimpleName());
97 public void onDetach() {
98 mContainerActivity
= null
;
104 * Interface to implement by any Activity that includes some instance of FileListFragment
105 * Interface to implement by any Activity that includes some instance of FileFragment
107 public interface ContainerActivity
extends ComponentsGetter
{
110 * Request the parent activity to show the details of an {@link OCFile}.
112 * @param file File to show details
114 public void showDetails(OCFile file
);
117 ///// TO UNIFY IN A SINGLE CALLBACK METHOD - EVENT NOTIFICATIONs -> something happened
118 // inside the fragment, MAYBE activity is interested --> unify in notification method
120 * Callback method invoked when a the user browsed into a different folder through the
125 public void onBrowsedDownTo(OCFile folder
);
128 * Callback method invoked when a the 'transfer state' of a file changes.
130 * This happens when a download or upload is started or ended for a file.
132 * This method is necessary by now to update the user interface of the double-pane layout
133 * in tablets because methods {@link FileDownloaderBinder#isDownloading(Account, OCFile)}
134 * and {@link FileUploaderBinder#isUploading(Account, OCFile)}
135 * won't provide the needed response before the method where this is called finishes.
137 * TODO Remove this when the transfer state of a file is kept in the database
140 * @param file OCFile which state changed.
141 * @param downloading Flag signaling if the file is now downloading.
142 * @param uploading Flag signaling if the file is now uploading.
144 public void onTransferStateChanged(OCFile file
, boolean downloading
, boolean uploading
);