Search in sources :

Example 6 with DefaultDividerDecoration

use of io.github.ryanhoo.music.ui.common.DefaultDividerDecoration in project StylishMusicPlayer by ryanhoo.

the class FileSystemActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_file_system);
    ButterKnife.bind(this);
    supportActionBar(toolbar);
    DEFAULT_SDCARD_NAME = getString(R.string.mp_activity_title_file_system);
    mFileTreeStack = new FileTreeStack();
    mAdapter = new FileSystemAdapter(this, null);
    mAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(int position) {
            FileWrapper fileWrapper = mAdapter.getItem(position);
            if (isInActionMode()) {
                toggleItemView(fileWrapper, position, !fileWrapper.selected);
            } else {
                File file = fileWrapper.file;
                if (file.isDirectory()) {
                    storeSnapshot();
                    toolbar.setTitle(getToolbarTitle(file));
                    loadFiles(file);
                }
            }
        }
    });
    mAdapter.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public void onItemClick(int position) {
            FileWrapper fileWrapper = mAdapter.getItem(position);
            if (fileWrapper.file.isDirectory()) {
                if (mActionModeCallback == null || !mActionModeCallback.isShowing()) {
                    startActionMode();
                }
                toggleItemView(fileWrapper, position, !fileWrapper.selected);
            }
        }
    });
    recyclerView.setAdapter(mAdapter);
    recyclerView.addItemDecoration(new DefaultDividerDecoration());
    loadFiles(SDCARD);
}
Also used : OnItemClickListener(io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener) File(java.io.File) DefaultDividerDecoration(io.github.ryanhoo.music.ui.common.DefaultDividerDecoration) OnItemLongClickListener(io.github.ryanhoo.music.ui.base.adapter.OnItemLongClickListener)

Aggregations

DefaultDividerDecoration (io.github.ryanhoo.music.ui.common.DefaultDividerDecoration)6 OnItemClickListener (io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener)5 Folder (io.github.ryanhoo.music.data.model.Folder)2 PlayList (io.github.ryanhoo.music.data.model.PlayList)1 Song (io.github.ryanhoo.music.data.model.Song)1 PlayListNowEvent (io.github.ryanhoo.music.event.PlayListNowEvent)1 PlaySongEvent (io.github.ryanhoo.music.event.PlaySongEvent)1 OnItemLongClickListener (io.github.ryanhoo.music.ui.base.adapter.OnItemLongClickListener)1 File (java.io.File)1