X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/e98fc8b141fed66cbdd265aaebd2cfa3affb68ac..c6124920d1137c8f53fdd3560e8e1070ea28f0ca:/src/com/owncloud/android/ui/activity/FileDisplayActivity.java diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 398a833d..7e60776d 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -1255,26 +1255,36 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { /** - * Class waiting for broadcast events from the {@link FielDownloader} service. + * Class waiting for broadcast events from the {@link FileDownloader} service. * * Updates the UI when a download is started or finished, provided that it is relevant for the * current folder. */ private class DownloadFinishReceiver extends BroadcastReceiver { + + //int refreshCounter = 0; @Override public void onReceive(Context context, Intent intent) { try { boolean sameAccount = isSameAccount(context, intent); String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH); boolean isDescendant = isDescendant(downloadedRemotePath); - + if (sameAccount && isDescendant) { - refreshListOfFilesFragment(); - refreshSecondFragment(intent.getAction(), downloadedRemotePath, intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false)); + String linkedToRemotePath = intent.getStringExtra(FileDownloader.EXTRA_LINKED_TO_PATH); + if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) { + //Log_OC.v(TAG, "refresh #" + ++refreshCounter); + refreshListOfFilesFragment(); + } + refreshSecondFragment( + intent.getAction(), + downloadedRemotePath, + intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false) + ); } if (mWaitingToSend != null) { - mWaitingToSend = getStorageManager().getFileByPath(mWaitingToSend.getRemotePath()); // Update the file to send + mWaitingToSend = getStorageManager().getFileByPath(mWaitingToSend.getRemotePath()); if (mWaitingToSend.isDown()) { sendDownloadedFile(); } @@ -1289,7 +1299,19 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { private boolean isDescendant(String downloadedRemotePath) { OCFile currentDir = getCurrentDir(); - return (currentDir != null && downloadedRemotePath != null && downloadedRemotePath.startsWith(currentDir.getRemotePath())); + return ( + currentDir != null && + downloadedRemotePath != null && + downloadedRemotePath.startsWith(currentDir.getRemotePath()) + ); + } + + private boolean isAscendant(String linkedToRemotePath) { + OCFile currentDir = getCurrentDir(); + return ( + currentDir != null && + currentDir.getRemotePath().startsWith(linkedToRemotePath) + ); } private boolean isSameAccount(Context context, Intent intent) { @@ -1725,6 +1747,7 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { private void requestForDownload() { Account account = getAccount(); + //if (!mWaitingToPreview.isDownloading()) { if (!mDownloaderBinder.isDownloading(account, mWaitingToPreview)) { Intent i = new Intent(this, FileDownloader.class); i.putExtra(FileDownloader.EXTRA_ACCOUNT, account); @@ -1782,7 +1805,7 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { private void requestForDownload(OCFile file) { Account account = getAccount(); - if (!mDownloaderBinder.isDownloading(account, file)) { + if (!mDownloaderBinder.isDownloading(account, mWaitingToPreview)) { Intent i = new Intent(this, FileDownloader.class); i.putExtra(FileDownloader.EXTRA_ACCOUNT, account); i.putExtra(FileDownloader.EXTRA_FILE, file);