X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/6d4ce68a81abaf0e37998ee9913986d6c2ebf1cc..6cfa24f55ab605770df08a6bed889bfccf0c0888:/src/com/owncloud/android/ui/fragment/FileDetailFragment.java diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index 2735e5ee..0ee824d2 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -69,7 +69,6 @@ import com.owncloud.android.DisplayUtils; import com.owncloud.android.authenticator.AccountAuthenticator; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; -import com.owncloud.android.files.services.FileDownloader; import com.owncloud.android.files.services.FileObserverService; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; @@ -120,7 +119,7 @@ public class FileDetailFragment extends SherlockFragment implements private Account mAccount; private FileDataStorageManager mStorageManager; - private DownloadFinishReceiver mDownloadFinishReceiver; + //private DownloadFinishReceiver mDownloadFinishReceiver; private UploadFinishReceiver mUploadFinishReceiver; public ProgressListener mProgressListener; @@ -203,7 +202,7 @@ public class FileDetailFragment extends SherlockFragment implements mProgressListener = new ProgressListener(progressBar); } - updateFileDetails(false); + updateFileDetails(false, false); return view; } @@ -230,7 +229,7 @@ public class FileDetailFragment extends SherlockFragment implements public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (mAccount != null) { - mStorageManager = new FileDataStorageManager(mAccount, getActivity().getApplicationContext().getContentResolver());; + mStorageManager = new FileDataStorageManager(mAccount, getActivity().getApplicationContext().getContentResolver()); } } @@ -255,13 +254,15 @@ public class FileDetailFragment extends SherlockFragment implements public void onResume() { super.onResume(); + /* mDownloadFinishReceiver = new DownloadFinishReceiver(); IntentFilter filter = new IntentFilter( FileDownloader.DOWNLOAD_FINISH_MESSAGE); getActivity().registerReceiver(mDownloadFinishReceiver, filter); + */ mUploadFinishReceiver = new UploadFinishReceiver(); - filter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE); + IntentFilter filter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE); getActivity().registerReceiver(mUploadFinishReceiver, filter); } @@ -271,11 +272,17 @@ public class FileDetailFragment extends SherlockFragment implements public void onPause() { super.onPause(); - getActivity().unregisterReceiver(mDownloadFinishReceiver); - mDownloadFinishReceiver = null; + /* + if (mDownloadFinishReceiver != null) { + getActivity().unregisterReceiver(mDownloadFinishReceiver); + mDownloadFinishReceiver = null; + } + */ - getActivity().unregisterReceiver(mUploadFinishReceiver); - mUploadFinishReceiver = null; + if (mUploadFinishReceiver != null) { + getActivity().unregisterReceiver(mUploadFinishReceiver); + mUploadFinishReceiver = null; + } } @@ -296,7 +303,7 @@ public class FileDetailFragment extends SherlockFragment implements } leaveTransferProgress(); } - + @Override public View getView() { @@ -583,7 +590,7 @@ public class FileDetailFragment extends SherlockFragment implements mStorageManager = new FileDataStorageManager(ocAccount, getActivity().getApplicationContext().getContentResolver()); } mAccount = ocAccount; - updateFileDetails(false); + updateFileDetails(false, false); } @@ -597,12 +604,17 @@ public class FileDetailFragment extends SherlockFragment implements * @param transferring Flag signaling if the file should be considered as downloading or uploading, * although {@link FileDownloaderBinder#isDownloading(Account, OCFile)} and * {@link FileUploaderBinder#isUploading(Account, OCFile)} return false. - * + * + * @param refresh If 'true', try to refresh the hold file from the database */ - public void updateFileDetails(boolean transferring) { + public void updateFileDetails(boolean transferring, boolean refresh) { if (readyToShow()) { + if (refresh && mStorageManager != null) { + mFile = mStorageManager.getFileByPath(mFile.getRemotePath()); + } + // set file details setFilename(mFile.getFileName()); setFiletype(mFile.getMimetype()); @@ -803,31 +815,6 @@ public class FileDetailFragment extends SherlockFragment implements /** - * Once the file download has finished -> update view - * @author Bartek Przybylski - */ - private class DownloadFinishReceiver extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME); - - if (!isEmpty() && accountName.equals(mAccount.name)) { - boolean downloadWasFine = intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false); - String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH); - if (mFile.getRemotePath().equals(downloadedRemotePath)) { - if (downloadWasFine) { - mFile = mStorageManager.getFileByPath(downloadedRemotePath); - } - mContainerActivity.notifySuccessfulDownload(mFile, intent, downloadWasFine); - getActivity().removeStickyBroadcast(intent); - updateFileDetails(false); // it updates the buttons; must be called although !downloadWasFine - } - } - } - } - - - /** * Once the file upload has finished -> update view * * Being notified about the finish of an upload is necessary for the next sequence: @@ -857,7 +844,7 @@ public class FileDetailFragment extends SherlockFragment implements msg.show(); } getSherlockActivity().removeStickyBroadcast(intent); // not the best place to do this; a small refactorization of BroadcastReceivers should be done - updateFileDetails(false); // it updates the buttons; must be called although !uploadWasFine; interrupted uploads still leave an incomplete file in the server + updateFileDetails(false, false); // it updates the buttons; must be called although !uploadWasFine; interrupted uploads still leave an incomplete file in the server } } }