Search in sources :

Example 1 with FileListAdapter

use of com.frostwire.android.gui.adapters.menu.FileListAdapter in project frostwire by frostwire.

the class MyFilesFragment method updateFiles.

private void updateFiles(Object[] data) {
    if (data == null || data.length < 2 || data[1] == null) {
        LOG.warn("Something wrong, data is null");
        return;
    }
    try {
        byte fileType = (Byte) data[0];
        @SuppressWarnings("unchecked") List<FileDescriptor> items = (List<FileDescriptor>) data[1];
        adapter = new FileListAdapter(getActivity(), items, fileType, selectAllModeOn) {

            @Override
            protected void onLocalPlay() {
                if (adapter != null) {
                    saveListViewVisiblePosition(adapter.getFileType());
                }
            }

            @Override
            protected void onItemChecked(View v, boolean isChecked) {
                super.onItemChecked(v, isChecked);
                autoCheckUnCheckSelectAllCheckbox();
                selectionModeCallback.onItemChecked(getActivity(), adapter.getCheckedCount());
            }

            @Override
            protected boolean onItemLongClicked(View v) {
                return onFileItemLongClicked(v);
            }

            @Override
            protected void onItemClicked(View v) {
                onFileItemClicked(v);
            }
        };
        adapter.setCheckboxesVisibility(selectAllModeOn);
        list.setNumColumns(adapter.getNumColumns());
        restorePreviouslyChecked();
        if (previousFilter != null) {
            performFilter(previousFilter);
        } else {
            updateAdapter();
        }
    } catch (Throwable e) {
        LOG.error("Error updating files in list", e);
    }
}
Also used : FileListAdapter(com.frostwire.android.gui.adapters.menu.FileListAdapter) List(java.util.List) ArrayList(java.util.ArrayList) GridView(android.widget.GridView) SearchView(android.support.v7.widget.SearchView) View(android.view.View) TextView(android.widget.TextView) FileDescriptor(com.frostwire.android.core.FileDescriptor)

Aggregations

SearchView (android.support.v7.widget.SearchView)1 View (android.view.View)1 GridView (android.widget.GridView)1 TextView (android.widget.TextView)1 FileDescriptor (com.frostwire.android.core.FileDescriptor)1 FileListAdapter (com.frostwire.android.gui.adapters.menu.FileListAdapter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1