X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/b66e309dfa8b145a293cb47b7cbcf588dc0c79ab..e1245bbda7894e1a3028d2b54a6918e4bdd46ae2:/src/com/owncloud/android/files/services/FileObserverService.java diff --git a/src/com/owncloud/android/files/services/FileObserverService.java b/src/com/owncloud/android/files/services/FileObserverService.java index 8a63a6ee..fa1fec24 100644 --- a/src/com/owncloud/android/files/services/FileObserverService.java +++ b/src/com/owncloud/android/files/services/FileObserverService.java @@ -22,13 +22,14 @@ import java.io.File; import java.util.HashMap; import java.util.Map; -import com.owncloud.android.Log_OC; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.db.ProviderMeta.ProviderTableMeta; import com.owncloud.android.files.OwnCloudFileObserver; import com.owncloud.android.operations.SynchronizeFileOperation; import com.owncloud.android.utils.FileStorageUtils; +import com.owncloud.android.utils.Log_OC; + import android.accounts.Account; import android.accounts.AccountManager; @@ -57,9 +58,6 @@ public class FileObserverService extends Service { private static DownloadCompletedReceiverBis mDownloadReceiver; private IBinder mBinder = new LocalBinder(); - private String mDownloadAddedMessage; - private String mDownloadFinishMessage; - public class LocalBinder extends Binder { FileObserverService getService() { return FileObserverService.this; @@ -71,13 +69,9 @@ public class FileObserverService extends Service { super.onCreate(); mDownloadReceiver = new DownloadCompletedReceiverBis(); - FileDownloader downloader = new FileDownloader(); - mDownloadAddedMessage = downloader.getDownloadAddedMessage(); - mDownloadFinishMessage= downloader.getDownloadFinishMessage(); - IntentFilter filter = new IntentFilter(); - filter.addAction(mDownloadAddedMessage); - filter.addAction(mDownloadFinishMessage); + filter.addAction(FileDownloader.getDownloadAddedMessage()); + filter.addAction(FileDownloader.getDownloadFinishMessage()); registerReceiver(mDownloadReceiver, filter); mObserversMap = new HashMap(); @@ -168,8 +162,7 @@ public class FileObserverService extends Service { OwnCloudFileObserver observer = new OwnCloudFileObserver( path, account, - getApplicationContext(), - OwnCloudFileObserver.CHANGES_ONLY); + getApplicationContext()); mObserversMap.put(path, observer); if (new File(path).exists()) { observer.startWatching(); @@ -208,8 +201,7 @@ public class FileObserverService extends Service { /// the local file was never registered to observe before observer = new OwnCloudFileObserver( localPath, account, - getApplicationContext(), - OwnCloudFileObserver.CHANGES_ONLY); + getApplicationContext()); mObserversMap.put(localPath, observer); Log_OC.d(TAG, "Observer added for path " + localPath); @@ -267,12 +259,12 @@ public class FileObserverService extends Service { String downloadPath = intent.getStringExtra(FileDownloader.EXTRA_FILE_PATH); OwnCloudFileObserver observer = mObserversMap.get(downloadPath); if (observer != null) { - if (intent.getAction().equals(mDownloadFinishMessage) && + if (intent.getAction().equals(FileDownloader.getDownloadFinishMessage()) && new File(downloadPath).exists()) { // the download could be successful. not; in both cases, the file could be down, due to a former download or upload observer.startWatching(); Log_OC.d(TAG, "Watching again " + downloadPath); - } else if (intent.getAction().equals(mDownloadAddedMessage)) { + } else if (intent.getAction().equals(FileDownloader.getDownloadAddedMessage())) { observer.stopWatching(); Log_OC.d(TAG, "Disabling observance of " + downloadPath); }