Search in sources :

Example 1 with FolderView

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)));
}
Also used : R(com.simplecity.amp_library.R) Bundle(android.os.Bundle) Rx.onErrorLogAndRethrow(com.afollestad.aesthetic.Rx.onErrorLogAndRethrow) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) BindView(butterknife.BindView) Song(com.simplecity.amp_library.model.Song) Aesthetic(com.afollestad.aesthetic.Aesthetic) CheckBox(android.widget.CheckBox) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) Unbinder(butterknife.Unbinder) BackPressListener(test.com.androidnavigation.fragment.BackPressListener) LogUtils(com.simplecity.amp_library.utils.LogUtils) ContextualToolbarHelper(com.simplecity.amp_library.utils.ContextualToolbarHelper) SortManager(com.simplecity.amp_library.utils.SortManager) FileHelper(com.simplecity.amp_library.utils.FileHelper) PopupMenu(android.support.v7.widget.PopupMenu) ViewGroup(android.view.ViewGroup) Breadcrumb(com.simplecity.amp_library.interfaces.Breadcrumb) SettingsManager(com.simplecity.amp_library.utils.SettingsManager) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) InclExclItem(com.simplecity.amp_library.model.InclExclItem) IntStream(com.annimon.stream.IntStream) BreadcrumbListener(com.simplecity.amp_library.interfaces.BreadcrumbListener) FileType(com.simplecity.amp_library.interfaces.FileType) AppBarLayout(android.support.design.widget.AppBarLayout) Stream(com.annimon.stream.Stream) ContextualToolbar(com.simplecity.amp_library.ui.views.ContextualToolbar) RecyclerListener(com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener) ButterKnife(butterknife.ButterKnife) DrawerLockManager(com.simplecity.amp_library.ui.drawer.DrawerLockManager) ViewModelAdapter(com.simplecityapps.recycler_adapter.adapter.ViewModelAdapter) SelectableViewModel(com.simplecity.amp_library.ui.modelviews.SelectableViewModel) Single(io.reactivex.Single) FolderView(com.simplecity.amp_library.ui.modelviews.FolderView) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) ViewBackgroundAction(com.afollestad.aesthetic.ViewBackgroundAction) BaseFileObject(com.simplecity.amp_library.model.BaseFileObject) Observable(io.reactivex.Observable) UpgradeDialog(com.simplecity.amp_library.ui.dialog.UpgradeDialog) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) Rx.distinctToMainThread(com.afollestad.aesthetic.Rx.distinctToMainThread) Nullable(io.reactivex.annotations.Nullable) Collectors(com.annimon.stream.Collectors) FileBrowser(com.simplecity.amp_library.utils.FileBrowser) LayoutInflater(android.view.LayoutInflater) Function3(io.reactivex.functions.Function3) ThemedStatusBarView(com.simplecity.amp_library.ui.views.ThemedStatusBarView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TextUtils(android.text.TextUtils) File(java.io.File) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar) BreadcrumbItem(com.simplecity.amp_library.ui.views.BreadcrumbItem) BreadcrumbsView(com.simplecity.amp_library.ui.modelviews.BreadcrumbsView) DataManager(com.simplecity.amp_library.utils.DataManager) Collections(java.util.Collections) FolderView(com.simplecity.amp_library.ui.modelviews.FolderView) List(java.util.List) ArrayList(java.util.ArrayList) File(java.io.File) SuppressLint(android.annotation.SuppressLint)

Example 2 with FolderView

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));
    }
}
Also used : R(com.simplecity.amp_library.R) ActionMode(android.view.ActionMode) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) PlaylistUtils(com.simplecity.amp_library.utils.PlaylistUtils) DrawableCompat(android.support.v4.graphics.drawable.DrawableCompat) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Song(com.simplecity.amp_library.model.Song) FileObject(com.simplecity.amp_library.model.FileObject) Schedulers(rx.schedulers.Schedulers) View(android.view.View) BackPressListener(com.simplecity.amp_library.interfaces.BackPressListener) PreferenceManager(android.preference.PreferenceManager) ActionBarUtils(com.simplecity.amp_library.utils.ActionBarUtils) SortManager(com.simplecity.amp_library.utils.SortManager) AsyncTask(android.os.AsyncTask) Playlist(com.simplecity.amp_library.model.Playlist) MainActivity(com.simplecity.amp_library.ui.activities.MainActivity) FileHelper(com.simplecity.amp_library.utils.FileHelper) PopupMenu(android.support.v7.widget.PopupMenu) SubMenu(android.view.SubMenu) Breadcrumb(com.simplecity.amp_library.interfaces.Breadcrumb) WhitelistHelper(com.simplecity.amp_library.sql.databases.WhitelistHelper) SettingsManager(com.simplecity.amp_library.utils.SettingsManager) ViewGroup(android.view.ViewGroup) ViewUtils(com.simplecity.amp_library.utils.ViewUtils) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) TextView(android.widget.TextView) FolderAdapter(com.simplecity.amp_library.ui.adapters.FolderAdapter) AdaptableItem(com.simplecity.amp_library.model.AdaptableItem) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) BreadcrumbListener(com.simplecity.amp_library.interfaces.BreadcrumbListener) FileType(com.simplecity.amp_library.interfaces.FileType) Context(android.content.Context) Stream(com.annimon.stream.Stream) DrawableUtils(com.simplecity.amp_library.utils.DrawableUtils) FolderView(com.simplecity.amp_library.ui.modelviews.FolderView) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) ThemeUtils(com.simplecity.amp_library.utils.ThemeUtils) ColorUtils(com.simplecity.amp_library.utils.ColorUtils) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) BaseFileObject(com.simplecity.amp_library.model.BaseFileObject) Menu(android.view.Menu) CustomMediaScanner(com.simplecity.amp_library.utils.CustomMediaScanner) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) TaggerDialog(com.simplecity.amp_library.tagger.TaggerDialog) Collectors(com.annimon.stream.Collectors) FileBrowser(com.simplecity.amp_library.utils.FileBrowser) LayoutInflater(android.view.LayoutInflater) FolderObject(com.simplecity.amp_library.model.FolderObject) ProgressDialog(android.app.ProgressDialog) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TextUtils(android.text.TextUtils) File(java.io.File) DialogUtils(com.simplecity.amp_library.utils.DialogUtils) Color(android.graphics.Color) RecyclerView(android.support.v7.widget.RecyclerView) SharedPreferences(android.content.SharedPreferences) BreadcrumbItem(com.simplecity.amp_library.ui.views.BreadcrumbItem) Toolbar(android.support.v7.widget.Toolbar) BreadcrumbsView(com.simplecity.amp_library.ui.modelviews.BreadcrumbsView) CustomEditText(com.simplecity.amp_library.ui.views.CustomEditText) Collections(java.util.Collections) FolderView(com.simplecity.amp_library.ui.modelviews.FolderView) AdaptableItem(com.simplecity.amp_library.model.AdaptableItem)

Example 3 with FolderView

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();
}
Also used : R(com.simplecity.amp_library.R) Bundle(android.os.Bundle) Rx.onErrorLogAndRethrow(com.afollestad.aesthetic.Rx.onErrorLogAndRethrow) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) BindView(butterknife.BindView) Song(com.simplecity.amp_library.model.Song) Aesthetic(com.afollestad.aesthetic.Aesthetic) CheckBox(android.widget.CheckBox) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) Unbinder(butterknife.Unbinder) BackPressListener(test.com.androidnavigation.fragment.BackPressListener) LogUtils(com.simplecity.amp_library.utils.LogUtils) ContextualToolbarHelper(com.simplecity.amp_library.utils.ContextualToolbarHelper) SortManager(com.simplecity.amp_library.utils.SortManager) FileHelper(com.simplecity.amp_library.utils.FileHelper) PopupMenu(android.support.v7.widget.PopupMenu) ViewGroup(android.view.ViewGroup) Breadcrumb(com.simplecity.amp_library.interfaces.Breadcrumb) SettingsManager(com.simplecity.amp_library.utils.SettingsManager) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) InclExclItem(com.simplecity.amp_library.model.InclExclItem) IntStream(com.annimon.stream.IntStream) BreadcrumbListener(com.simplecity.amp_library.interfaces.BreadcrumbListener) FileType(com.simplecity.amp_library.interfaces.FileType) AppBarLayout(android.support.design.widget.AppBarLayout) Stream(com.annimon.stream.Stream) ContextualToolbar(com.simplecity.amp_library.ui.views.ContextualToolbar) RecyclerListener(com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener) ButterKnife(butterknife.ButterKnife) DrawerLockManager(com.simplecity.amp_library.ui.drawer.DrawerLockManager) ViewModelAdapter(com.simplecityapps.recycler_adapter.adapter.ViewModelAdapter) SelectableViewModel(com.simplecity.amp_library.ui.modelviews.SelectableViewModel) Single(io.reactivex.Single) FolderView(com.simplecity.amp_library.ui.modelviews.FolderView) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) ViewBackgroundAction(com.afollestad.aesthetic.ViewBackgroundAction) BaseFileObject(com.simplecity.amp_library.model.BaseFileObject) Observable(io.reactivex.Observable) UpgradeDialog(com.simplecity.amp_library.ui.dialog.UpgradeDialog) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) Rx.distinctToMainThread(com.afollestad.aesthetic.Rx.distinctToMainThread) Nullable(io.reactivex.annotations.Nullable) Collectors(com.annimon.stream.Collectors) FileBrowser(com.simplecity.amp_library.utils.FileBrowser) LayoutInflater(android.view.LayoutInflater) Function3(io.reactivex.functions.Function3) ThemedStatusBarView(com.simplecity.amp_library.ui.views.ThemedStatusBarView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TextUtils(android.text.TextUtils) File(java.io.File) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar) BreadcrumbItem(com.simplecity.amp_library.ui.views.BreadcrumbItem) BreadcrumbsView(com.simplecity.amp_library.ui.modelviews.BreadcrumbsView) DataManager(com.simplecity.amp_library.utils.DataManager) Collections(java.util.Collections) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

Bundle (android.os.Bundle)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 PopupMenu (android.support.v7.widget.PopupMenu)3 RecyclerView (android.support.v7.widget.RecyclerView)3 Toolbar (android.support.v7.widget.Toolbar)3 TextUtils (android.text.TextUtils)3 LayoutInflater (android.view.LayoutInflater)3 Menu (android.view.Menu)3 MenuInflater (android.view.MenuInflater)3 MenuItem (android.view.MenuItem)3 View (android.view.View)3 ViewGroup (android.view.ViewGroup)3 Toast (android.widget.Toast)3 Collectors (com.annimon.stream.Collectors)3 Stream (com.annimon.stream.Stream)3 R (com.simplecity.amp_library.R)3 Breadcrumb (com.simplecity.amp_library.interfaces.Breadcrumb)3 BreadcrumbListener (com.simplecity.amp_library.interfaces.BreadcrumbListener)3 FileType (com.simplecity.amp_library.interfaces.FileType)3 BaseFileObject (com.simplecity.amp_library.model.BaseFileObject)3