OC-577: Modify FileDataStorageManager to call updateSubtreeSize. OC-523

This commit is contained in:
masensio 2013-07-05 14:54:02 +02:00
parent a7385a7a5a
commit a52ff9359f
3 changed files with 20 additions and 61 deletions

View file

@ -25,6 +25,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import com.owncloud.android.DisplayUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.db.ProviderMeta;
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
@ -186,6 +187,9 @@ public class FileDataStorageManager implements DataStorageManager {
for (OCFile f : getDirectoryContent(file))
saveFile(f);
Log_OC.d(TAG, ".........file Time= " + DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
updateSubtreeSize(file.getParentId());
return overriden;
}
@ -494,6 +498,8 @@ public class FileDataStorageManager implements DataStorageManager {
if (removeDBData) {
removeFile(dir, true);
}
updateSubtreeSize(dir.getParentId());
}
}

View file

@ -73,6 +73,7 @@ public class CreateFolderOperation extends RemoteOperation {
OCFile newDir = new OCFile(mRemotePath);
newDir.setMimetype("DIR");
newDir.setParentId(mParentDirId);
newDir.setModificationTimestamp(System.currentTimeMillis());
mStorageManager.saveFile(newDir);
}

View file

@ -33,7 +33,6 @@ import android.widget.ListView;
import android.widget.TextView;
import com.owncloud.android.DisplayUtils;
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.DataStorageManager;
@ -56,9 +55,6 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
private DataStorageManager mStorageManager;
private Account mAccount;
private TransferServiceGetter mTransferServiceGetter;
//total size of a directory (recursive)
private Long totalSizeOfDirectoriesRecursive = null;
private Long lastModifiedOfAllSubdirectories = null;
public FileListListAdapter(OCFile file, DataStorageManager storage_man,
Context context, TransferServiceGetter transferServiceGetter) {
@ -174,21 +170,9 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
lastModV.setVisibility(View.VISIBLE);
lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
// getDirectorySizeNumber(file,true);
// if (lastModifiedOfAllSubdirectories == null)
// {
// lastModV.setVisibility(View.GONE);
// fileSizeV.setVisibility(View.GONE);
// }
// else
// {
// lastModV.setVisibility(View.VISIBLE);
// lastModV.setText(DisplayUtils.unixTimeToHumanReadable(lastModifiedOfAllSubdirectories));
// fileSizeV.setVisibility(View.VISIBLE);
// fileSizeV.setText(DisplayUtils.bytesToHumanReadable((totalSizeOfDirectoriesRecursive == null) ? 0 : totalSizeOfDirectoriesRecursive));
// }
checkBoxV.setVisibility(View.GONE);
view.findViewById(R.id.imageView3).setVisibility(View.GONE);
checkBoxV.setVisibility(View.GONE);
view.findViewById(R.id.imageView3).setVisibility(View.GONE);
}
}
@ -196,38 +180,6 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
}
/**
* - This method counts recursively all subdirectories and their files from the root directory.
* - It also shows a timestamp of the last modificated file inside the root directory
*
* @param OCFile : startDirectory
* @param boolean : counting starts from here ?
*/
private void getDirectorySizeNumber(OCFile directory,boolean startOfRecursive) {
if (startOfRecursive) {
totalSizeOfDirectoriesRecursive = null;
}
Vector<OCFile> files = mStorageManager.getDirectoryContent(directory);
for (OCFile file : files) {
if(!file.isDirectory()) {
if (totalSizeOfDirectoriesRecursive == null) {
totalSizeOfDirectoriesRecursive = file.getFileLength();
lastModifiedOfAllSubdirectories = file.getModificationTimestamp();
continue;
}
totalSizeOfDirectoriesRecursive += file.getFileLength();
if (lastModifiedOfAllSubdirectories < file.getModificationTimestamp()) {
lastModifiedOfAllSubdirectories = file.getModificationTimestamp();
}
}
else {
this.getDirectorySizeNumber(file, false);
}
}
}
@Override
public int getViewTypeCount() {
return 1;