Merge branch 'download_folder__refactoring_observance_of_downloads_in_progress' into...
authorjabarros <jabarros@solidgear.es>
Tue, 20 Jan 2015 11:42:27 +0000 (12:42 +0100)
committerjabarros <jabarros@solidgear.es>
Tue, 20 Jan 2015 11:42:27 +0000 (12:42 +0100)
1  2 
src/com/owncloud/android/datamodel/OCFile.java
src/com/owncloud/android/files/services/FileDownloader.java

@@@ -70,8 -70,6 +70,8 @@@ public class OCFile implements Parcelab
  
      private boolean mNeedsUpdateThumbnail;
  
 +    private boolean mIsDownloading;
 +
  
      /**
       * Create new {@link OCFile} with given path.
          mPermissions = source.readString();
          mRemoteId = source.readString();
          mNeedsUpdateThumbnail = source.readInt() == 0;
 +        mIsDownloading = source.readInt() == 0;
  
      }
  
          dest.writeString(mPermissions);
          dest.writeString(mRemoteId);
          dest.writeInt(mNeedsUpdateThumbnail ? 1 : 0);
 +        dest.writeInt(mIsDownloading ? 1 : 0);
      }
  
      /**
          mPermissions = null;
          mRemoteId = null;
          mNeedsUpdateThumbnail = false;
 +        mIsDownloading = false;
      }
  
      /**
          this.mRemoteId = remoteId;
      }
  
 -    public boolean isSynchronizing() {
 -        // TODO real implementation
 -        return false;
 +    public boolean isDownloading() {
 +        return mIsDownloading;
      }
  
 -    public boolean isDownloading() {
 +    public void setDownloading(boolean isDownloading) {
 +        this.mIsDownloading = isDownloading;
 +    }
 +
++    public boolean isSynchronizing() {
+         // TODO real implementation
+         return false;
+     }
 -
  }
@@@ -169,12 -169,6 +169,12 @@@ public class FileDownloader extends Ser
                      newDownload.addDatatransferProgressListener(this);
                      newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder);
                      requestedDownloads.add(downloadKey);
 +
 +                    // Store file on db with state 'downloading'
 +                    FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver());
 +                    file.setDownloading(true);
 +                    storageManager.saveFile(file);
 +
                      sendBroadcastNewDownload(newDownload);
  
                  } catch (IllegalArgumentException e) {
           * @param account       Owncloud account where the remote file is stored.
           * @param file          A file that could be in the queue of downloads.
           */
+         /*
          public boolean isDownloading(Account account, OCFile file) {
              if (account == null || file == null) return false;
              String targetKey = buildRemoteName(account, file);
                  }
              }
          }
+         */
  
          
          /**
          file.setStoragePath(mCurrentDownload.getSavePath());
          file.setFileLength((new File(mCurrentDownload.getSavePath()).length()));
          file.setRemoteId(mCurrentDownload.getFile().getRemoteId());
 +        file.setDownloading(false);
          mStorageManager.saveFile(file);
          mStorageManager.triggerMediaScan(file.getStoragePath());
      }