use of com.cyl.musiclake.bean.Playlist in project MusicLake by caiyonglong.
the class NeteaseMusicListActivity method showAddPlaylistDialog.
@Override
public void showAddPlaylistDialog(List<Playlist> playlists, Music music) {
if (playlists == null) {
ToastUtils.show("暂无歌单");
return;
}
new MaterialDialog.Builder(this).title("增加到歌单").items(playlists).itemsCallback((dialog, itemView, which, text) -> {
Playlist playlist = playlists.get(which);
Log.d("addDialog", which + "----" + playlists.get(which).getId() + "------" + music.getId());
mPresenter.collectMusic(playlist.getId(), music);
}).build().show();
}
use of com.cyl.musiclake.bean.Playlist in project MusicLake by caiyonglong.
the class DBDaoImpl method getAllPlaylistForCursor.
@Override
public List<Playlist> getAllPlaylistForCursor(Cursor cursor) {
List<Playlist> results = new ArrayList<>();
// 再遍历游标cursor,获取数据库中的值
LogUtil.d(TAG, cursor.getCount() + "----");
if (cursor.getCount() > 0) {
while (cursor.moveToNext()) {
Playlist playlist = new MusicCursorWrapper(cursor).getPlaylist();
LogUtil.d(TAG, playlist.toString() + "----");
results.add(playlist);
}
}
// 记得关闭游标
cursor.close();
return results;
}
use of com.cyl.musiclake.bean.Playlist in project MusicLake by caiyonglong.
the class PlaylistDetailFragment method onOptionsItemSelected.
@SuppressLint("ResourceAsColor")
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch(id) {
case R.id.action_delete_playlist:
new MaterialDialog.Builder(getContext()).title("提示").content("是否删除这个歌单?").onPositive((dialog, which) -> {
mPresenter.deletePlaylist(mPlaylist);
// PlaylistLoader.deletePlaylist(getActivity(), mPlaylist.getId());
// RxBus.getInstance().post(new Playlist());
// onBackPress();
}).positiveText("确定").negativeText("取消").show();
break;
case R.id.action_rename_playlist:
new MaterialDialog.Builder(getActivity()).title("重命名歌单").positiveText("确定").negativeText("取消").inputRangeRes(2, 10, R.color.red).inputType(InputType.TYPE_CLASS_TEXT).input("输入歌单名", mPlaylist.getName(), false, (dialog, input) -> Log.e("=====", input.toString())).onPositive((dialog, which) -> {
String title = dialog.getInputEditText().getText().toString();
mPresenter.renamePlaylist(mPlaylist, title);
}).positiveText("确定").negativeText("取消").show();
break;
case R.id.action_share:
Intent intent3 = new Intent(getActivity(), EditActivity.class);
StringBuilder content = new StringBuilder();
if (musicList.size() > 0) {
content = new StringBuilder("分享歌单\n");
}
for (int i = 0; i < musicList.size(); i++) {
content.append(musicList.get(i).getTitle()).append("---").append(musicList.get(i).getArtist());
content.append("\n");
}
intent3.putExtra("content", content.toString());
startActivity(intent3);
break;
case R.id.action_add:
List<String> titles = new ArrayList<>();
List<Music> addMusicList = SongLoader.getSongsForDB(getContext());
for (Music music : addMusicList) {
titles.add(music.getTitle() + "-" + music.getArtist());
}
new MaterialDialog.Builder(getActivity()).title("新增歌曲").iconRes(R.drawable.ic_playlist_add).content("快速添加歌曲,更加方便地添加所需要的歌曲到当前目录").positiveText("确定").items(titles).itemsCallbackMultiChoice(null, (dialog, which, text) -> false).onPositive((dialog, which) -> {
dialog.dismiss();
int sum = dialog.getSelectedIndices().length, num = 0;
for (int i = 0; i < sum; i++) {
int index = dialog.getSelectedIndices()[i];
boolean success = PlaylistLoader.addToPlaylist(getContext(), mPlaylist.getId(), addMusicList.get(index).getId());
if (success) {
num++;
}
}
mPresenter.loadPlaylistSongs(mPlaylist.getId());
mPresenter.loadPlaylistArt(mPlaylist.getId());
ToastUtils.show(getContext(), num + "首添加成功," + (sum - num) + "首已存在此歌单添加失败");
RxBus.getInstance().post(new Playlist());
}).show();
break;
}
return super.onOptionsItemSelected(item);
}
use of com.cyl.musiclake.bean.Playlist in project MusicLake by caiyonglong.
the class PlaylistFragment method updateView.
/**
* 异步刷新数据
*/
public void updateView(final long id) {
final List<Playlist> playlists = PlaylistLoader.getPlaylist(getActivity());
mAdapter.notifyDataSetChanged();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
for (int i = 0; i < playlists.size(); i++) {
long playlistid = Long.parseLong(playlists.get(i).getId());
if (playlistid == id) {
mMultiViewPager.setCurrentItem(i);
break;
}
}
}
}, 200);
}
use of com.cyl.musiclake.bean.Playlist in project MusicLake by caiyonglong.
the class SearchActivity method showAddPlaylistDialog.
@Override
public void showAddPlaylistDialog(List<Playlist> playlists, Music music) {
if (playlists == null) {
new MaterialDialog.Builder(this).title("增加到歌单").content("暂无歌单").build().show();
return;
}
new MaterialDialog.Builder(this).title("增加到歌单").items(playlists).itemsCallback((dialog, itemView, which, text) -> {
Playlist playlist = playlists.get(which);
Log.d("addDialog", which + "----" + playlists.get(which).getId() + "------" + music.getId());
mPresenter.collectMusic(playlist.getId(), music);
}).build().show();
}
Aggregations