Search in sources :

Example 1 with DividerItemDecoration

use of io.hefuyi.listener.widget.DividerItemDecoration in project ListenerMusicPlayer by hefuyicoder.

the class PlayqueueDialog method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (mSwatch != null) {
        root.setBackgroundColor(mSwatch.getRgb());
        mAdapter.setPaletteSwatch(mSwatch);
        int blackWhiteColor = ColorUtil.getBlackWhiteColor(mSwatch.getRgb());
        tvPlayMode.setTextColor(blackWhiteColor);
        ivPlayMode.setColorFilter(blackWhiteColor);
        clearAll.setColorFilter(blackWhiteColor);
    }
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setAdapter(mAdapter);
    recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST, false));
    int shuffleMode = MusicPlayer.getShuffleMode();
    int repeatMode = MusicPlayer.getRepeatMode();
    if (shuffleMode == MusicService.SHUFFLE_NONE) {
        if (repeatMode == MusicService.REPEAT_CURRENT) {
            //单曲播放模式
            ivPlayMode.setImageDrawable(getResources().getDrawable(R.drawable.ic_one_shot));
            tvPlayMode.setText(R.string.repeat_current);
            mPlayMode = PlayMode.CURRENT;
        } else {
            //顺序播放模式
            ivPlayMode.setImageDrawable(getResources().getDrawable(R.drawable.ic_list_repeat));
            tvPlayMode.setText(R.string.repeat_all);
            mPlayMode = PlayMode.REPEATALL;
        }
    } else if (shuffleMode == MusicService.SHUFFLE_NORMAL || shuffleMode == MusicService.SHUFFLE_AUTO) {
        //随机播放模式
        ivPlayMode.setImageDrawable(getResources().getDrawable(R.drawable.ic_list_shuffle));
        tvPlayMode.setText(R.string.shuffle_all);
        mPlayMode = PlayMode.SHUFFLE;
    }
    mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {

        @Override
        public void onItemRangeRemoved(int positionStart, int itemCount) {
            if (mAdapter.getItemCount() == 0) {
                dismiss();
            }
        }
    });
    mPresenter.subscribe();
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(io.hefuyi.listener.widget.DividerItemDecoration)

Example 2 with DividerItemDecoration

use of io.hefuyi.listener.widget.DividerItemDecoration in project ListenerMusicPlayer by hefuyicoder.

the class ArtistMusicFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    ATE.apply(this, ATEUtil.getATEKey(getActivity()));
    songsRecyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
    songsRecyclerview.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST, true));
    mSongAdapter = new ArtistSongAdapter(getActivity(), null, artistID);
    songsRecyclerview.setAdapter(mSongAdapter);
    mPresenter.subscribe(artistID);
    subscribeMetaChangedEvent();
}
Also used : ArtistSongAdapter(io.hefuyi.listener.ui.adapter.ArtistSongAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(io.hefuyi.listener.widget.DividerItemDecoration)

Example 3 with DividerItemDecoration

use of io.hefuyi.listener.widget.DividerItemDecoration in project ListenerMusicPlayer by hefuyicoder.

the class PlaylistDetailFragment method onViewCreated.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    ATE.apply(this, ATEUtil.getATEKey(getActivity()));
    if (getArguments().getBoolean("transition")) {
        playlistArt.setTransitionName(getArguments().getString("transition_name"));
    }
    recyclerView.setAdapter(mAdapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST, false));
    setupToolbar();
    mPresenter.loadPlaylistSongs(playlistID);
    mPresenter.loadPlaylistArt(firstAlbumID);
    //监听歌曲删除事件,修改歌单封面
    mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {

        @Override
        public void onItemRangeRemoved(int positionStart, int itemCount) {
            super.onItemRangeRemoved(positionStart, itemCount);
            RxBus.getInstance().post(new PlaylistUpdateEvent());
            if (positionStart == 0) {
                List<Song> songs = mAdapter.getSongList();
                if (songs.size() == 0) {
                    firstAlbumID = -1;
                } else {
                    firstAlbumID = songs.get(0).albumId;
                }
                mPresenter.loadPlaylistArt(firstAlbumID);
            }
        }
    });
    subscribeMetaChangedEvent();
}
Also used : PlaylistUpdateEvent(io.hefuyi.listener.event.PlaylistUpdateEvent) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(io.hefuyi.listener.widget.DividerItemDecoration) TargetApi(android.annotation.TargetApi)

Example 4 with DividerItemDecoration

use of io.hefuyi.listener.widget.DividerItemDecoration in project ListenerMusicPlayer by hefuyicoder.

the class PlaylistFragment method setItemDecoration.

private void setItemDecoration() {
    if (isGrid) {
        int spacingInPixels = getActivity().getResources().getDimensionPixelSize(R.dimen.spacing_card_album_grid);
        itemDecoration = new PlaylistFragment.SpacesItemDecoration(spacingInPixels);
    } else {
        itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST, false);
    }
    recyclerView.addItemDecoration(itemDecoration);
}
Also used : DividerItemDecoration(io.hefuyi.listener.widget.DividerItemDecoration)

Example 5 with DividerItemDecoration

use of io.hefuyi.listener.widget.DividerItemDecoration in project ListenerMusicPlayer by hefuyicoder.

the class FoldersFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ATE.apply(this, ATEUtil.getATEKey(getActivity()));
    if (Build.VERSION.SDK_INT < 21 && view.findViewById(R.id.status_bar) != null) {
        view.findViewById(R.id.status_bar).setVisibility(View.GONE);
        if (Build.VERSION.SDK_INT >= 19) {
            int statusBarHeight = DensityUtil.getStatusBarHeight(getContext());
            view.findViewById(R.id.toolbar).setPadding(0, statusBarHeight, 0, 0);
        }
    }
    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setTitle(R.string.folders);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setAdapter(mAdapter);
    recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST, false));
    mPresenter.subscribe();
    subscribeMetaChangedEvent();
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(io.hefuyi.listener.widget.DividerItemDecoration) ActionBar(android.support.v7.app.ActionBar)

Aggregations

DividerItemDecoration (io.hefuyi.listener.widget.DividerItemDecoration)10 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 TargetApi (android.annotation.TargetApi)2 ActionBar (android.support.v7.app.ActionBar)2 AppCompatActivity (android.support.v7.app.AppCompatActivity)2 RecyclerView (android.support.v7.widget.RecyclerView)2 PlaylistUpdateEvent (io.hefuyi.listener.event.PlaylistUpdateEvent)1 ArtistSongAdapter (io.hefuyi.listener.ui.adapter.ArtistSongAdapter)1 List (java.util.List)1