use of com.simplecity.amp_library.interfaces.Breadcrumb in project Shuttle by timusus.
the class FolderFragment method changeDir.
@SuppressLint("CheckResult")
public void changeDir(File newDir) {
if (setItemsDisposable != null) {
setItemsDisposable.dispose();
}
disposables.add(Single.zip(DataManager.getInstance().getIncludeItems().first(Collections.emptyList()), DataManager.getInstance().getExcludeItems().first(Collections.emptyList()), Single.fromCallable(() -> {
final String path = FileHelper.getPath(newDir);
if (TextUtils.isEmpty(path)) {
return new ArrayList<>();
}
currentDir = path;
return fileBrowser.loadDir(new File(path));
}), (Function3<List<InclExclItem>, List<InclExclItem>, List<BaseFileObject>, List<ViewModel>>) (whitelist, blacklist, baseFileObjects) -> {
List<ViewModel> items = Stream.of(baseFileObjects).map(baseFileObject -> {
// Look for an existing FolderView wrapping the BaseFileObject, we'll reuse it if it exists.
FolderView folderView = (FolderView) Stream.of(adapter.items).filter(viewModel -> viewModel instanceof FolderView && (((FolderView) viewModel).baseFileObject.equals(baseFileObject))).findFirst().orElse(null);
if (folderView == null) {
folderView = new FolderView(baseFileObject, Stream.of(whitelist).anyMatch(inclExclItem -> inclExclItem.path.equals(baseFileObject.path)), Stream.of(blacklist).anyMatch(inclExclItem -> inclExclItem.path.equals(baseFileObject.path)));
folderView.setShowWhitelist(isShowingWhitelist);
folderView.setShowBlacklist(isShowingBlacklist);
folderView.setClickListener(FolderFragment.this);
}
return folderView;
}).collect(Collectors.toList());
if (showBreadcrumbsInList && breadcrumbsView != null) {
breadcrumbsView.setBreadcrumbsPath(currentDir);
breadcrumbsView.setListener(FolderFragment.this);
items.add(0, breadcrumbsView);
}
return items;
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(adaptableItems -> {
if (adapter != null) {
setItemsDisposable = adapter.setItems(adaptableItems);
}
if (breadcrumb != null) {
breadcrumb.changeBreadcrumbPath(currentDir);
}
if (adapter != null) {
changeBreadcrumbPath();
}
updateMenuItems();
}, error -> LogUtils.logException(TAG, "Error changing dir", error)));
}
Aggregations