Merge branch 'develop' into download_folder
[pub/Android/ownCloud.git] / src / com / owncloud / android / files / services / FileDownloader.java
index 2519b6b..eb870e1 100644 (file)
@@ -96,9 +96,6 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
     private NotificationCompat.Builder mNotificationBuilder;
     private int mLastPercent;
 
     private NotificationCompat.Builder mNotificationBuilder;
     private int mLastPercent;
 
-    private Account mAccount;
-    private OCFile mFile;
-    
     
     public static String getDownloadAddedMessage() {
         return FileDownloader.class.getName().toString() + DOWNLOAD_ADDED_MESSAGE;
     
     public static String getDownloadAddedMessage() {
         return FileDownloader.class.getName().toString() + DOWNLOAD_ADDED_MESSAGE;
@@ -150,24 +147,24 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
             Log_OC.e(TAG, "Not enough information provided in intent");
             return START_NOT_STICKY;
         } else {
             Log_OC.e(TAG, "Not enough information provided in intent");
             return START_NOT_STICKY;
         } else {
-            mAccount = intent.getParcelableExtra(EXTRA_ACCOUNT);
-            mFile = intent.getParcelableExtra(EXTRA_FILE);
+            final Account account = intent.getParcelableExtra(EXTRA_ACCOUNT);
+            final OCFile file = intent.getParcelableExtra(EXTRA_FILE);
 
             if (ACTION_CANCEL_FILE_DOWNLOAD.equals(intent.getAction())) {
 
                 new Thread(new Runnable() {
                     public void run() {
                         // Cancel the download
 
             if (ACTION_CANCEL_FILE_DOWNLOAD.equals(intent.getAction())) {
 
                 new Thread(new Runnable() {
                     public void run() {
                         // Cancel the download
-                        cancel(mAccount,mFile);
+                        cancel(account, file);
                     }
                 }).start();
 
             } else {
 
                 AbstractList<String> requestedDownloads = new Vector<String>(); // dvelasco: now this always contains just one element, but that can change in a near future (download of multiple selection)
                     }
                 }).start();
 
             } else {
 
                 AbstractList<String> requestedDownloads = new Vector<String>(); // dvelasco: now this always contains just one element, but that can change in a near future (download of multiple selection)
-                String downloadKey = buildRemoteName(mAccount, mFile);
+                String downloadKey = buildRemoteName(account, file);
                 try {
                 try {
-                    DownloadFileOperation newDownload = new DownloadFileOperation(mAccount, mFile);
+                    DownloadFileOperation newDownload = new DownloadFileOperation(account, file);
                     mPendingDownloads.putIfAbsent(downloadKey, newDownload);
                     newDownload.addDatatransferProgressListener(this);
                     newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder);
                     mPendingDownloads.putIfAbsent(downloadKey, newDownload);
                     newDownload.addDatatransferProgressListener(this);
                     newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder);
@@ -580,12 +577,6 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
      * @param file          File OCFile
      */
     public void cancel(Account account, OCFile file){
      * @param file          File OCFile
      */
     public void cancel(Account account, OCFile file){
-        if(Looper.myLooper() == Looper.getMainLooper()) {
-            Log_OC.d(TAG, "Current Thread is Main Thread.");
-        } else {
-            Log_OC.d(TAG, "Current Thread is NOT Main Thread.");
-        }
-
         DownloadFileOperation download = null;
         String targetKey = buildRemoteName(account, file);
         ArrayList<String> keyItems = new ArrayList<String>();
         DownloadFileOperation download = null;
         String targetKey = buildRemoteName(account, file);
         ArrayList<String> keyItems = new ArrayList<String>();
@@ -602,6 +593,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
                     }
                 }
             } else {
                     }
                 }
             } else {
+                // this is not really expected...
                 Log_OC.d(TAG, "Canceling file download");
                 keyItems.add(buildRemoteName(account, file));
             }
                 Log_OC.d(TAG, "Canceling file download");
                 keyItems.add(buildRemoteName(account, file));
             }