Search in sources :

Example 1 with OnItemClickListener

use of io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener in project StylishMusicPlayer by ryanhoo.

the class PlayListFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    mAdapter = new PlayListAdapter(getActivity(), null);
    mAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(int position) {
            PlayList playList = mAdapter.getItem(position);
            startActivity(PlayListDetailsActivity.launchIntentForPlayList(getActivity(), playList));
        }
    });
    mAdapter.setAddPlayListCallback(this);
    recyclerView.setAdapter(mAdapter);
    recyclerView.addItemDecoration(new DefaultDividerDecoration());
    new PlayListPresenter(AppRepository.getInstance(), this).subscribe();
}
Also used : PlayList(io.github.ryanhoo.music.data.model.PlayList) OnItemClickListener(io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener) DefaultDividerDecoration(io.github.ryanhoo.music.ui.common.DefaultDividerDecoration)

Example 2 with OnItemClickListener

use of io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener in project StylishMusicPlayer by ryanhoo.

the class PlayListDetailsActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    Folder folder = getIntent().getParcelableExtra(EXTRA_FOLDER);
    mPlayList = getIntent().getParcelableExtra(EXTRA_PLAY_LIST);
    if (folder == null && mPlayList == null) {
        Log.e(TAG, "onCreate: folder & play list can't be both null!");
        finish();
    }
    if (folder != null) {
        isFolder = true;
        mPlayList = PlayList.fromFolder(folder);
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_play_list_details);
    ButterKnife.bind(this);
    supportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle(mPlayList.getName());
    }
    mAdapter = new SongAdapter(this, mPlayList.getSongs());
    mAdapter.setActionCallback(this);
    mAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(int position) {
            RxBus.getInstance().post(new PlayListNowEvent(mPlayList, position));
        }
    });
    recyclerView.setAdapter(mAdapter);
    recyclerView.addItemDecoration(new DefaultDividerDecoration());
    emptyView.setVisibility(mPlayList.getNumOfSongs() > 0 ? View.GONE : View.VISIBLE);
    new PlayListDetailsPresenter(AppRepository.getInstance(), this).subscribe();
}
Also used : OnItemClickListener(io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener) Folder(io.github.ryanhoo.music.data.model.Folder) PlayListNowEvent(io.github.ryanhoo.music.event.PlayListNowEvent) DefaultDividerDecoration(io.github.ryanhoo.music.ui.common.DefaultDividerDecoration)

Example 3 with OnItemClickListener

use of io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener in project StylishMusicPlayer by ryanhoo.

the class AllLocalMusicFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    mAdapter = new LocalMusicAdapter(getActivity(), null);
    mAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(int position) {
            Song song = mAdapter.getItem(position);
            RxBus.getInstance().post(new PlaySongEvent(song));
        }
    });
    recyclerView.setAdapter(mAdapter);
    recyclerView.addItemDecoration(new DefaultDividerDecoration());
    fastScroller.setRecyclerView(recyclerView);
    new LocalMusicPresenter(AppRepository.getInstance(), this).subscribe();
}
Also used : Song(io.github.ryanhoo.music.data.model.Song) OnItemClickListener(io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener) PlaySongEvent(io.github.ryanhoo.music.event.PlaySongEvent) DefaultDividerDecoration(io.github.ryanhoo.music.ui.common.DefaultDividerDecoration)

Example 4 with OnItemClickListener

use of io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener in project StylishMusicPlayer by ryanhoo.

the class FolderFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    mAdapter = new FolderAdapter(getActivity(), null);
    mAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(int position) {
            Folder folder = mAdapter.getItem(position);
            startActivity(PlayListDetailsActivity.launchIntentForFolder(getActivity(), folder));
        }
    });
    mAdapter.setAddFolderCallback(this);
    recyclerView.setAdapter(mAdapter);
    recyclerView.addItemDecoration(new DefaultDividerDecoration());
    new FolderPresenter(AppRepository.getInstance(), this).subscribe();
}
Also used : OnItemClickListener(io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener) Folder(io.github.ryanhoo.music.data.model.Folder) DefaultDividerDecoration(io.github.ryanhoo.music.ui.common.DefaultDividerDecoration)

Example 5 with OnItemClickListener

use of io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener 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

OnItemClickListener (io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener)5 DefaultDividerDecoration (io.github.ryanhoo.music.ui.common.DefaultDividerDecoration)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