+ Log_OC.e(TAG, "Fail to update desendants of " + dir.getFileId() + " in database", e);
+ }
+
+ }
+ }
+
+ @Override
+ public Vector<OCFile> getDirectoryImages(OCFile directory) {
+ Vector<OCFile> ret = new Vector<OCFile>();
+ if (directory != null) {
+ // TODO better implementation, filtering in the access to database (if possible) instead of here
+ Vector<OCFile> tmp = getDirectoryContent(directory);
+ OCFile current = null;
+ for (int i=0; i<tmp.size(); i++) {
+ current = tmp.get(i);
+ if (current.isImage()) {
+ ret.add(current);
+ }
+ }
+ }
+ return ret;
+ }
+
+ /**
+ * Calculate and save the folderSize on DB
+ * @param id
+ */
+ @Override
+ public void calculateFolderSize(long id) {
+ long folderSize = 0;
+
+ Vector<OCFile> files = getDirectoryContent(id);
+
+ for (OCFile f: files)
+ {
+ folderSize = folderSize + f.getFileLength();
+ }
+
+ updateSize(id, folderSize);
+ }
+
+ /**
+ * Update the size value of an OCFile in DB
+ */
+ private int updateSize(long id, long size) {
+ ContentValues cv = new ContentValues();
+ cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, size);
+ int result = -1;
+ if (getContentResolver() != null) {
+ result = getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, ProviderTableMeta._ID + "=?",
+ new String[] { String.valueOf(id) });
+ } else {
+ try {
+ result = getContentProvider().update(ProviderTableMeta.CONTENT_URI, cv, ProviderTableMeta._ID + "=?",
+ new String[] { String.valueOf(id) });
+ } catch (RemoteException e) {
+ Log_OC.e(TAG,"Fail to update size column into database " + e.getMessage());