use of com.simplecity.amp_library.ui.modelviews.FolderView 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)));
}
use of com.simplecity.amp_library.ui.modelviews.FolderView in project Shuttle by timusus.
the class FolderFragment method showCheckboxes.
public void showCheckboxes(boolean show) {
mShowCheckboxes = show;
List<AdaptableItem> folderViews = Stream.of(mAdapter.items).filter(adaptableItem -> adaptableItem instanceof FolderView).collect(Collectors.toList());
for (AdaptableItem adaptableItem : folderViews) {
((FolderView) adaptableItem).setShowCheckboxes(mShowCheckboxes);
mAdapter.notifyItemChanged(mAdapter.items.indexOf(adaptableItem));
}
}
use of com.simplecity.amp_library.ui.modelviews.FolderView in project Shuttle by timusus.
the class FolderFragment method onFileObjectOverflowClick.
@Override
public void onFileObjectOverflowClick(View v, FolderView folderView) {
PopupMenu menu = new PopupMenu(getActivity(), v);
MenuUtils.setupFolderMenu(menu, folderView.baseFileObject);
menu.setOnMenuItemClickListener(MenuUtils.getFolderMenuClickListener(getContext(), folderView.baseFileObject, taggerDialog -> {
if (!ShuttleUtils.isUpgraded()) {
UpgradeDialog.getUpgradeDialog(getActivity()).show();
} else {
taggerDialog.show(getFragmentManager());
}
}, null, () -> IntStream.range(0, adapter.getItemCount()).filter(i -> adapter.items.get(i) == folderView).findFirst().ifPresent(i -> adapter.notifyItemChanged(i)), () -> IntStream.range(0, adapter.getItemCount()).filter(i -> adapter.items.get(i) == folderView).findFirst().ifPresent(i -> adapter.notifyItemRemoved(i))));
menu.show();
}
Aggregations