use of com.simplecity.amp_library.ui.modelviews.BreadcrumbsView 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.BreadcrumbsView in project Shuttle by timusus.
the class FolderFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_folder_browser, container, false);
unbinder = ButterKnife.bind(this, rootView);
if (displayedInTabs) {
breadcrumbsView = new BreadcrumbsView(currentDir);
showBreadcrumbsInList = true;
changeBreadcrumbPath();
appBarLayout.setVisibility(View.GONE);
statusBarView.setVisibility(View.GONE);
} else {
showBreadcrumbsInList = false;
breadcrumb.addBreadcrumbListener(this);
if (!TextUtils.isEmpty(currentDir)) {
breadcrumb.changeBreadcrumbPath(currentDir);
}
}
if (!displayedInTabs) {
toolbar.inflateMenu(R.menu.menu_folders);
toolbar.setNavigationOnClickListener(v -> getNavigationController().popViewController());
toolbar.setOnMenuItemClickListener(this);
updateMenuItems(toolbar.getMenu());
}
recyclerView.setRecyclerListener(new RecyclerListener());
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(adapter);
Aesthetic.get(getContext()).colorPrimary().take(1).subscribe(color -> ViewBackgroundAction.create(appBarLayout).accept(color), onErrorLogAndRethrow());
compositeDisposable.add(Aesthetic.get(getContext()).colorPrimary().compose(distinctToMainThread()).subscribe(color -> ViewBackgroundAction.create(appBarLayout).accept(color), onErrorLogAndRethrow()));
return rootView;
}
use of com.simplecity.amp_library.ui.modelviews.BreadcrumbsView in project Shuttle by timusus.
the class FolderFragment method changeDir.
@SuppressLint("CheckResult")
public void changeDir(File newDir) {
disposables.add(Single.zip(whitelistRepository.getWhitelistItems(songsRepository).first(Collections.emptyList()), blacklistRepository.getBlacklistItems(songsRepository).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, whitelistRepository, blacklistRepository, settingsManager, 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) {
analyticsManager.dropBreadcrumb(TAG, "setItems()");
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.BreadcrumbsView in project Shuttle by timusus.
the class FolderFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_folder_browser, container, false);
unbinder = ButterKnife.bind(this, rootView);
if (displayedInTabs) {
breadcrumbsView = new BreadcrumbsView(currentDir);
showBreadcrumbsInList = true;
changeBreadcrumbPath();
appBarLayout.setVisibility(View.GONE);
statusBarView.setVisibility(View.GONE);
} else {
showBreadcrumbsInList = false;
breadcrumb.addBreadcrumbListener(this);
if (!TextUtils.isEmpty(currentDir)) {
breadcrumb.changeBreadcrumbPath(currentDir);
}
}
if (!displayedInTabs) {
toolbar.inflateMenu(R.menu.menu_folders);
toolbar.setNavigationOnClickListener(v -> getNavigationController().popViewController());
toolbar.setOnMenuItemClickListener(this);
updateMenuItems(toolbar.getMenu());
}
recyclerView.setRecyclerListener(new RecyclerListener());
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(adapter);
compositeDisposable.add(Aesthetic.get(getContext()).colorPrimary().compose(distinctToMainThread()).subscribe(color -> ViewBackgroundAction.create(appBarLayout).accept(color), onErrorLogAndRethrow()));
return rootView;
}
use of com.simplecity.amp_library.ui.modelviews.BreadcrumbsView in project Shuttle by timusus.
the class FolderFragment method changeBreadcrumbPath.
public void changeBreadcrumbPath() {
List<AdaptableItem> breadcrumbViews = Stream.of(mAdapter.items).filter(adaptableItem -> adaptableItem instanceof BreadcrumbsView).collect(Collectors.toList());
for (AdaptableItem adaptableItem : breadcrumbViews) {
((BreadcrumbsView) adaptableItem).setBreadcrumbsPath(mCurrentDir);
mAdapter.notifyItemChanged(mAdapter.items.indexOf(adaptableItem));
}
}
Aggregations