From: jabarros Date: Tue, 20 Jan 2015 11:42:27 +0000 (+0100) Subject: Merge branch 'download_folder__refactoring_observance_of_downloads_in_progress' into... X-Git-Tag: oc-android-1.7.0_signed~23^2~8^2~1 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/d8ac7b2241bc99df58b5f4be4c3c4d83fc9efaf6?ds=inline;hp=-c Merge branch 'download_folder__refactoring_observance_of_downloads_in_progress' into download_folder_update_database --- d8ac7b2241bc99df58b5f4be4c3c4d83fc9efaf6 diff --combined src/com/owncloud/android/datamodel/OCFile.java index bda6166d,2ba0415a..e6fd4141 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.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. @@@ -114,7 -112,6 +114,7 @@@ mPermissions = source.readString(); mRemoteId = source.readString(); mNeedsUpdateThumbnail = source.readInt() == 0; + mIsDownloading = source.readInt() == 0; } @@@ -139,7 -136,6 +139,7 @@@ dest.writeString(mPermissions); dest.writeString(mRemoteId); dest.writeInt(mNeedsUpdateThumbnail ? 1 : 0); + dest.writeInt(mIsDownloading ? 1 : 0); } /** @@@ -352,7 -348,6 +352,7 @@@ mPermissions = null; mRemoteId = null; mNeedsUpdateThumbnail = false; + mIsDownloading = false; } /** @@@ -567,12 -562,14 +567,16 @@@ 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; + } - } diff --combined src/com/owncloud/android/files/services/FileDownloader.java index 59982771,ab9e3327..741e30a8 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@@ -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) { @@@ -259,6 -253,7 +259,7 @@@ * @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); @@@ -276,6 -271,7 +277,7 @@@ } } } + */ /** @@@ -421,7 -417,6 +423,7 @@@ 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()); }