use of us.koller.cameraroll.data.provider.itemLoader.FileLoader in project Camera-Roll-Android-App by kollerlukas.
the class StorageRetriever method loadFilesForDir.
public void loadFilesForDir(final Activity context, String dirPath, final FilesProvider.Callback callback) {
if (new File(dirPath).isFile()) {
callback.onDirLoaded(null);
return;
}
threads = new ArrayList<>();
Thread.Callback threadCallback = new Thread.Callback() {
@Override
public void done(Thread thread, ItemLoader.Result result) {
File_POJO files = result.files;
boolean filesContainMedia = false;
for (int i = 0; i < files.getChildren().size(); i++) {
if (files.getChildren().get(i) != null && MediaType.isMedia(files.getChildren().get(i).getPath())) {
filesContainMedia = true;
break;
}
}
if (filesContainMedia) {
SortUtil.sortByDate(files.getChildren());
} else {
SortUtil.sortByName(files.getChildren());
}
callback.onDirLoaded(files);
thread.cancel();
threads = null;
}
};
final File[] files = new File[] { new File(dirPath) };
Thread thread = new Thread(context, files, new FileLoader()).notSearchSubDirs().setCallback(threadCallback);
threads.add(thread);
thread.start();
}
Aggregations