(uploadedRemotePath.startsWith(currentDir.getRemotePath()));
if (sameAccount && isDescendant) {
- refreshListOfFilesFragment();
+ String linkedToRemotePath =
+ intent.getStringExtra(FileDownloader.EXTRA_LINKED_TO_PATH);
+ if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) {
+ refreshListOfFilesFragment();
+ }
}
boolean uploadWasFine = intent.getBooleanExtra(FileUploader.EXTRA_UPLOAD_RESULT,
}
+ // TODO refactor this receiver, and maybe DownloadFinishReceiver; this method is duplicated :S
+ private boolean isAscendant(String linkedToRemotePath) {
+ OCFile currentDir = getCurrentDir();
+ return (
+ currentDir != null &&
+ currentDir.getRemotePath().startsWith(linkedToRemotePath)
+ );
+ }
+
+
}
*/
private class DownloadFinishReceiver extends BroadcastReceiver {
- //int refreshCounter = 0;
@Override
public void onReceive(Context context, Intent intent) {
try {
- boolean sameAccount = isSameAccount(context, intent);
+ boolean sameAccount = isSameAccount(intent);
String downloadedRemotePath =
intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH);
boolean isDescendant = isDescendant(downloadedRemotePath);
String linkedToRemotePath =
intent.getStringExtra(FileDownloader.EXTRA_LINKED_TO_PATH);
if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) {
- //Log_OC.v(TAG, "refresh #" + ++refreshCounter);
refreshListOfFilesFragment();
}
refreshSecondFragment(
);
}
- private boolean isSameAccount(Context context, Intent intent) {
+ private boolean isSameAccount(Intent intent) {
String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME);
return (accountName != null && getAccount() != null &&
accountName.equals(getAccount().name));