Search in sources :

Example 1 with OCFileListAdapter

use of com.owncloud.android.ui.adapter.OCFileListAdapter in project android by nextcloud.

the class OCFileListFragment method selectAllFiles.

/**
 * De-/select all elements in the current list view.
 *
 * @param select <code>true</code> to select all, <code>false</code> to deselect all
 */
public void selectAllFiles(boolean select) {
    OCFileListAdapter ocFileListAdapter = (OCFileListAdapter) getRecyclerView().getAdapter();
    if (select) {
        ocFileListAdapter.addAllFilesToCheckedFiles();
    } else {
        ocFileListAdapter.removeAllFilesFromCheckedFiles();
    }
    for (int i = 0; i < mAdapter.getItemCount(); i++) {
        mAdapter.notifyItemChanged(i);
    }
    mActiveActionMode.invalidate();
}
Also used : OCFileListAdapter(com.owncloud.android.ui.adapter.OCFileListAdapter)

Example 2 with OCFileListAdapter

use of com.owncloud.android.ui.adapter.OCFileListAdapter in project android by nextcloud.

the class ExtendedListFragment method performSearch.

public void performSearch(final String query, boolean isBackPressed) {
    handler.removeCallbacksAndMessages(null);
    RecyclerView.Adapter adapter = getRecyclerView().getAdapter();
    Activity activity = getActivity();
    if (activity != null) {
        if (activity instanceof FileDisplayActivity) {
            if (isBackPressed && TextUtils.isEmpty(query)) {
                FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) activity;
                fileDisplayActivity.resetSearchView();
                fileDisplayActivity.updateListOfFilesFragment(true);
            } else {
                handler.post(() -> {
                    if (adapter instanceof OCFileListAdapter) {
                        if (accountManager.getUser().getServer().getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_20)) {
                            ((FileDisplayActivity) activity).performUnifiedSearch(query);
                        } else {
                            EventBus.getDefault().post(new SearchEvent(query, SearchRemoteOperation.SearchType.FILE_SEARCH));
                        }
                    } else if (adapter instanceof LocalFileListAdapter) {
                        LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) adapter;
                        localFileListAdapter.filter(query);
                    }
                });
                if (searchView != null) {
                    searchView.clearFocus();
                }
            }
        } else if (activity instanceof UploadFilesActivity) {
            LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) adapter;
            localFileListAdapter.filter(query);
            ((UploadFilesActivity) activity).showToolbarSpinner();
        } else if (activity instanceof FolderPickerActivity) {
            ((FolderPickerActivity) activity).refreshListOfFilesFragment(true);
        }
    }
}
Also used : FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) FolderPickerActivity(com.owncloud.android.ui.activity.FolderPickerActivity) UploadFilesActivity(com.owncloud.android.ui.activity.UploadFilesActivity) FolderPickerActivity(com.owncloud.android.ui.activity.FolderPickerActivity) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) Activity(android.app.Activity) RecyclerView(androidx.recyclerview.widget.RecyclerView) EmptyRecyclerView(com.owncloud.android.ui.EmptyRecyclerView) SearchEvent(com.owncloud.android.ui.events.SearchEvent) LocalFileListAdapter(com.owncloud.android.ui.adapter.LocalFileListAdapter) UploadFilesActivity(com.owncloud.android.ui.activity.UploadFilesActivity) OCFileListAdapter(com.owncloud.android.ui.adapter.OCFileListAdapter)

Example 3 with OCFileListAdapter

use of com.owncloud.android.ui.adapter.OCFileListAdapter in project android by nextcloud.

the class OCFileListFragment method onActivityCreated.

/**
 * {@inheritDoc}
 */
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Log_OC.i(TAG, "onActivityCreated() start");
    if (savedInstanceState != null) {
        mFile = savedInstanceState.getParcelable(KEY_FILE);
    }
    Bundle args = getArguments();
    mOnlyFoldersClickable = args != null && args.getBoolean(ARG_ONLY_FOLDERS_CLICKABLE, false);
    mFileSelectable = args != null && args.getBoolean(ARG_FILE_SELECTABLE, false);
    mLimitToMimeType = args != null ? args.getString(ARG_MIMETYPE, "") : "";
    boolean hideItemOptions = args != null && args.getBoolean(ARG_HIDE_ITEM_OPTIONS, false);
    mAdapter = new OCFileListAdapter(getActivity(), accountManager.getUser(), preferences, mContainerActivity, this, hideItemOptions, isGridViewPreferred(mFile));
    setRecyclerViewAdapter(mAdapter);
    mHideFab = args != null && args.getBoolean(ARG_HIDE_FAB, false);
    if (mHideFab) {
        setFabVisible(false);
    } else {
        setFabVisible(true);
        registerFabListener();
    }
    if (!searchFragment) {
        // do not touch search event if previously searched
        if (getArguments() == null) {
            searchEvent = null;
        } else {
            searchEvent = getArguments().getParcelable(OCFileListFragment.SEARCH_EVENT);
        }
    }
    prepareCurrentSearch(searchEvent);
    if (mSortButton != null) {
        mSortButton.setOnClickListener(v -> openSortingOrderDialogFragment(requireFragmentManager(), preferences.getSortOrderByFolder(mFile)));
    }
    if (mSwitchGridViewButton != null) {
        mSwitchGridViewButton.setOnClickListener(v -> {
            if (isGridEnabled()) {
                setListAsPreferred();
            } else {
                setGridAsPreferred();
            }
            setGridSwitchButton();
        });
    }
    setTitle();
    FragmentActivity fragmentActivity;
    if ((fragmentActivity = getActivity()) != null && fragmentActivity instanceof FileDisplayActivity) {
        FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) fragmentActivity;
        fileDisplayActivity.updateActionBarTitleAndHomeButton(fileDisplayActivity.getCurrentDir());
    }
    listDirectory(false, false);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) Bundle(android.os.Bundle) OCFileListAdapter(com.owncloud.android.ui.adapter.OCFileListAdapter)

Aggregations

OCFileListAdapter (com.owncloud.android.ui.adapter.OCFileListAdapter)3 FileDisplayActivity (com.owncloud.android.ui.activity.FileDisplayActivity)2 Activity (android.app.Activity)1 Bundle (android.os.Bundle)1 FragmentActivity (androidx.fragment.app.FragmentActivity)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 EmptyRecyclerView (com.owncloud.android.ui.EmptyRecyclerView)1 FolderPickerActivity (com.owncloud.android.ui.activity.FolderPickerActivity)1 UploadFilesActivity (com.owncloud.android.ui.activity.UploadFilesActivity)1 LocalFileListAdapter (com.owncloud.android.ui.adapter.LocalFileListAdapter)1 SearchEvent (com.owncloud.android.ui.events.SearchEvent)1