* Copyright (C) 2012-2013 ownCloud Inc.
*
* This program is free software: you can redistribute it and/or modify
* Copyright (C) 2012-2013 ownCloud Inc.
*
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License.
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
import com.owncloud.android.ui.fragment.FileFragment;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
import com.owncloud.android.ui.fragment.FileFragment;
public static final String EXTRA_FILE = "FILE";
public static final String EXTRA_ACCOUNT = "ACCOUNT";
public static final String EXTRA_FILE = "FILE";
public static final String EXTRA_ACCOUNT = "ACCOUNT";
* It's necessary to keep a public constructor without parameters; the system uses it when tries to reinstantiate a fragment automatically.
*/
public FileDownloadFragment() {
* It's necessary to keep a public constructor without parameters; the system uses it when tries to reinstantiate a fragment automatically.
*/
public FileDownloadFragment() {
* @param ignoreFirstSavedState Flag to work around an unexpected behaviour of {@link FragmentStatePagerAdapter}; TODO better solution
*/
public FileDownloadFragment(OCFile fileToDetail, Account ocAccount, boolean ignoreFirstSavedState) {
* @param ignoreFirstSavedState Flag to work around an unexpected behaviour of {@link FragmentStatePagerAdapter}; TODO better solution
*/
public FileDownloadFragment(OCFile fileToDetail, Account ocAccount, boolean ignoreFirstSavedState) {
mAccount = savedInstanceState.getParcelable(FileDownloadFragment.EXTRA_ACCOUNT);
mError = savedInstanceState.getBoolean(FileDownloadFragment.EXTRA_ERROR);
} else {
mAccount = savedInstanceState.getParcelable(FileDownloadFragment.EXTRA_ACCOUNT);
mError = savedInstanceState.getBoolean(FileDownloadFragment.EXTRA_ERROR);
} else {
ProgressBar progressBar = (ProgressBar)mView.findViewById(R.id.progressBar);
mProgressListener = new ProgressListener(progressBar);
ProgressBar progressBar = (ProgressBar)mView.findViewById(R.id.progressBar);
mProgressListener = new ProgressListener(progressBar);
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (mAccount != null) {
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (mAccount != null) {
outState.putParcelable(FileDownloadFragment.EXTRA_ACCOUNT, mAccount);
outState.putBoolean(FileDownloadFragment.EXTRA_ERROR, mError);
}
outState.putParcelable(FileDownloadFragment.EXTRA_ACCOUNT, mAccount);
outState.putBoolean(FileDownloadFragment.EXTRA_ERROR, mError);
}
- if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, mFile)) {
- downloaderBinder.cancel(mAccount, mFile);
+ if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile())) {
+ downloaderBinder.cancel(mAccount, getFile());
* Updates the view depending upon the state of the downloading file.
*
* @param transferring When true, the view must be updated assuming that the holded file is
* Updates the view depending upon the state of the downloading file.
*
* @param transferring When true, the view must be updated assuming that the holded file is
public void updateView(boolean transferring) {
// configure UI for depending upon local state of the file
FileDownloaderBinder downloaderBinder = (mContainerActivity == null) ? null : mContainerActivity.getFileDownloaderBinder();
public void updateView(boolean transferring) {
// configure UI for depending upon local state of the file
FileDownloaderBinder downloaderBinder = (mContainerActivity == null) ? null : mContainerActivity.getFileDownloaderBinder();
public void listenForTransferProgress() {
if (mProgressListener != null && !mListening) {
if (mContainerActivity.getFileDownloaderBinder() != null) {
public void listenForTransferProgress() {
if (mProgressListener != null && !mListening) {
if (mContainerActivity.getFileDownloaderBinder() != null) {
- mContainerActivity.getFileDownloaderBinder().addDatatransferProgressListener(mProgressListener, mAccount, mFile);
+ mContainerActivity.getFileDownloaderBinder().addDatatransferProgressListener(mProgressListener, mAccount, getFile());
public void leaveTransferProgress() {
if (mProgressListener != null) {
if (mContainerActivity.getFileDownloaderBinder() != null) {
public void leaveTransferProgress() {
if (mProgressListener != null) {
if (mContainerActivity.getFileDownloaderBinder() != null) {
- mContainerActivity.getFileDownloaderBinder().removeDatatransferProgressListener(mProgressListener, mAccount, mFile);
+ mContainerActivity.getFileDownloaderBinder().removeDatatransferProgressListener(mProgressListener, mAccount, getFile());