Search in sources :

Example 1 with OnlineMusic

use of com.huadong.musicvideoplayer.model.OnlineMusic in project MusicVideoPlayer by MartingKing.

the class OnlineMusicAdapter method getView.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_holder_music, parent, false);
        holder = new ViewHolder(convertView);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    OnlineMusic onlineMusic = mData.get(position);
    Glide.with(parent).load(onlineMusic.getPic_small()).apply(new RequestOptions().placeholder(R.drawable.default_cover).error(R.drawable.default_cover)).into(holder.ivCover);
    holder.tvTitle.setText(onlineMusic.getTitle());
    String artist = FileUtils.getArtistAndAlbum(onlineMusic.getArtist_name(), onlineMusic.getAlbum_title());
    holder.tvArtist.setText(artist);
    holder.ivMore.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mListener.onMoreClick(position);
        }
    });
    holder.vDivider.setVisibility(isShowDivider(position) ? View.VISIBLE : View.GONE);
    return convertView;
}
Also used : OnlineMusic(com.huadong.musicvideoplayer.model.OnlineMusic) RequestOptions(com.bumptech.glide.request.RequestOptions) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with OnlineMusic

use of com.huadong.musicvideoplayer.model.OnlineMusic in project MusicVideoPlayer by MartingKing.

the class PlaylistActivity method onMoreClick.

@Override
public void onMoreClick(int position) {
    final OnlineMusic onlineMusic = mMusicList.get(position);
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setTitle(mMusicList.get(position).getTitle());
    String path = FileUtils.getMusicDir() + FileUtils.getMp3FileName(onlineMusic.getArtist_name(), onlineMusic.getTitle());
    File file = new File(path);
    int itemsId = file.exists() ? R.array.online_music_dialog_without_download : R.array.online_music_dialog;
    dialog.setItems(itemsId, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch(which) {
                case // 分享
                0:
                    share(onlineMusic);
                    break;
                case // 查看歌手信息
                1:
                    artistInfo(onlineMusic);
                    break;
                case // 下载
                2:
                    download(onlineMusic);
                    break;
            }
        }
    });
    dialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OnlineMusic(com.huadong.musicvideoplayer.model.OnlineMusic) PlayOnlineMusic(com.huadong.musicvideoplayer.executor.PlayOnlineMusic) DownloadOnlineMusic(com.huadong.musicvideoplayer.executor.DownloadOnlineMusic) ShareOnlineMusic(com.huadong.musicvideoplayer.executor.ShareOnlineMusic) DialogInterface(android.content.DialogInterface) File(java.io.File)

Aggregations

OnlineMusic (com.huadong.musicvideoplayer.model.OnlineMusic)2 DialogInterface (android.content.DialogInterface)1 AlertDialog (android.support.v7.app.AlertDialog)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 RequestOptions (com.bumptech.glide.request.RequestOptions)1 DownloadOnlineMusic (com.huadong.musicvideoplayer.executor.DownloadOnlineMusic)1 PlayOnlineMusic (com.huadong.musicvideoplayer.executor.PlayOnlineMusic)1 ShareOnlineMusic (com.huadong.musicvideoplayer.executor.ShareOnlineMusic)1 File (java.io.File)1