use of com.amaze.filemanager.utils.OnProgressUpdate in project AmazeFileManager by TeamAmaze.
the class CountItemsOrAndSizeTask method doInBackground.
@Override
protected String doInBackground(Void[] params) {
String items = "";
long fileLength = file.length(context);
if (file.isDirectory(context)) {
final AtomicInteger x = new AtomicInteger(0);
file.forEachChildrenFile(context, false, new OnFileFound() {
@Override
public void onFileFound(HybridFileParcelable file) {
x.incrementAndGet();
}
});
final int folderLength = x.intValue();
long folderSize;
if (isStorage) {
folderSize = file.getUsableSpace();
} else {
folderSize = FileUtils.folderSize(file, new OnProgressUpdate<Long>() {
@Override
public void onUpdate(Long data) {
publishProgress(new Pair<>(folderLength, data));
}
});
}
items = getText(folderLength, folderSize, false);
} else {
items = Formatter.formatFileSize(context, fileLength) + (" (" + fileLength + " " + // truncation is insignificant
context.getResources().getQuantityString(R.plurals.bytes, (int) fileLength) + ")");
}
return items;
}
Aggregations