use of com.wm.remusic.info.Playlist in project remusic by aa112901.
the class PlaylistInfo method getPlaylist.
public synchronized ArrayList<Playlist> getPlaylist() {
ArrayList<Playlist> results = new ArrayList<>();
Cursor cursor = null;
try {
cursor = mMusicDatabase.getReadableDatabase().query(PlaylistInfoColumns.NAME, null, null, null, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
results.ensureCapacity(cursor.getCount());
do {
if (cursor.getString(4).equals("local"))
results.add(new Playlist(cursor.getLong(0), cursor.getString(1), cursor.getInt(2), cursor.getString(3), cursor.getString(4)));
} while (cursor.moveToNext());
}
return results;
} finally {
if (cursor != null) {
cursor.close();
cursor = null;
}
}
}
use of com.wm.remusic.info.Playlist in project remusic by aa112901.
the class AddNetPlaylistDialog method onCreateView.
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
// 设置无标题
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
if (getArguments() != null) {
musics = getArguments().getParcelableArrayList("songs");
author = getArguments().getString("author");
}
playlistInfo = PlaylistInfo.getInstance(mContext);
playlistsManager = PlaylistsManager.getInstance(mContext);
View view = inflater.inflate(R.layout.fragment_add_playlist, container);
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.create_new_playlist);
recyclerView = (RecyclerView) view.findViewById(R.id.add_playlist_recyclerview);
linearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final AlertDialog alertDialog = new AlertDialog.Builder(mContext).create();
alertDialog.setView((mContext.getLayoutInflater().inflate(R.layout.dialog, null)));
alertDialog.show();
Window window = alertDialog.getWindow();
window.setContentView(R.layout.dialog);
final EditText editText = (EditText) (window.findViewById(R.id.message));
editText.requestFocus();
(window.findViewById(R.id.positiveButton)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertDialog.dismiss();
}
});
(window.findViewById(R.id.negativeButton)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
new Thread(new Runnable() {
@Override
public void run() {
Log.e("addplay", "here");
String albumart = null;
for (MusicInfo info : musics) {
albumart = info.albumData;
if (info.islocal) {
if (albumart.equals(MusicUtils.getAlbumdata(MainApplication.context, info.songId)))
break;
} else if (!TextUtils.isEmpty(albumart)) {
break;
}
}
long playlistid = editText.getText().hashCode();
playlistInfo.addPlaylist(playlistid, editText.getText().toString(), musics.size(), albumart, author);
playlistsManager.insertLists(mContext, playlistid, musics);
Intent intent = new Intent(IConstants.PLAYLIST_COUNT_CHANGED);
MainApplication.context.sendBroadcast(intent);
}
}).start();
alertDialog.dismiss();
}
});
}
});
ArrayList<Playlist> playlists = playlistInfo.getPlaylist();
recyclerView.setLayoutManager(layoutManager);
AddPlaylistAdapter adapter = new AddPlaylistAdapter(playlists);
recyclerView.setAdapter(adapter);
// setItemDecoration();
return view;
}
use of com.wm.remusic.info.Playlist in project remusic by aa112901.
the class MainFragmentAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
switch(getItemViewType(i)) {
case 0:
MainFragmentItem item = (MainFragmentItem) itemResults.get(i);
itemHolder.itemtitle.setText(item.title);
itemHolder.count.setText("(" + item.count + ")");
itemHolder.image.setImageResource(item.avatar);
itemHolder.image.setImageTintList(R.color.theme_color_primary);
setOnListener(itemHolder, i);
break;
case 1:
Playlist playlist = (Playlist) itemResults.get(i);
if (createdExpanded && playlist.author.equals("local")) {
if (playlist.albumArt != null)
itemHolder.albumArt.setImageURI(Uri.parse(playlist.albumArt));
itemHolder.title.setText(playlist.name);
itemHolder.songcount.setText(playlist.songCount + "首");
}
if (collectExpanded && !playlist.author.equals("local")) {
if (playlist.albumArt != null)
itemHolder.albumArt.setImageURI(Uri.parse(playlist.albumArt));
itemHolder.title.setText(playlist.name);
itemHolder.songcount.setText(playlist.songCount + "首");
}
setOnPlaylistListener(itemHolder, i, playlist.id, playlist.albumArt, playlist.name);
isLoveList = false;
break;
case 2:
itemHolder.sectionItem.setText("创建的歌单" + "(" + playlists.size() + ")");
itemHolder.sectionImg.setImageResource(R.drawable.list_icn_arr_right);
setSectionListener(itemHolder, i);
break;
case 3:
itemHolder.sectionItem.setText("收藏的歌单" + "(" + netplaylists.size() + ")");
itemHolder.sectionImg.setImageResource(R.drawable.list_icn_arr_right);
setSectionListener(itemHolder, i);
break;
}
}
use of com.wm.remusic.info.Playlist in project remusic by aa112901.
the class PlaylistInfo method getNetPlaylist.
public synchronized ArrayList<Playlist> getNetPlaylist() {
ArrayList<Playlist> results = new ArrayList<>();
Cursor cursor = null;
try {
cursor = mMusicDatabase.getReadableDatabase().query(PlaylistInfoColumns.NAME, null, null, null, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
results.ensureCapacity(cursor.getCount());
do {
if (!cursor.getString(4).equals("local"))
results.add(new Playlist(cursor.getLong(0), cursor.getString(1), cursor.getInt(2), cursor.getString(3), cursor.getString(4)));
} while (cursor.moveToNext());
}
return results;
} finally {
if (cursor != null) {
cursor.close();
cursor = null;
}
}
}
use of com.wm.remusic.info.Playlist in project remusic by aa112901.
the class AddPlaylistDialog method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
// 设置无标题
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
if (getArguments() != null) {
musicId = getArguments().getLongArray("songs");
}
playlistInfo = PlaylistInfo.getInstance(getContext());
playlistsManager = PlaylistsManager.getInstance(getContext());
View view = inflater.inflate(R.layout.fragment_add_playlist, container);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.create_new_playlist);
recyclerView = (RecyclerView) view.findViewById(R.id.add_playlist_recyclerview);
linearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final AlertDialog alertDialog = new AlertDialog.Builder(getContext()).create();
alertDialog.setView((getActivity().getLayoutInflater().inflate(R.layout.dialog, null)));
alertDialog.show();
Window window = alertDialog.getWindow();
window.setContentView(R.layout.dialog);
final EditText editText = (EditText) (window.findViewById(R.id.message));
editText.requestFocus();
(window.findViewById(R.id.positiveButton)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertDialog.dismiss();
}
});
(window.findViewById(R.id.negativeButton)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
new Thread(new Runnable() {
@Override
public void run() {
String albumart = null;
for (long id : musicId) {
albumart = MusicUtils.getAlbumdata(MainApplication.context, id);
if (albumart != null) {
break;
}
}
// String albumart = MusicUtils.getMusicInfo(getContext(), musicId[0]).albumData;
playlistInfo.addPlaylist(editText.getText().hashCode(), editText.getText().toString(), musicId.length, "file://" + albumart, "local");
for (int i = 0; i < musicId.length; i++) {
playlistsManager.insert(MainApplication.context, editText.getText().hashCode(), musicId[i], i);
}
Intent intent = new Intent(IConstants.PLAYLIST_COUNT_CHANGED);
MainApplication.context.sendBroadcast(intent);
}
}).start();
alertDialog.dismiss();
}
});
}
});
ArrayList<Playlist> playlists = playlistInfo.getPlaylist();
recyclerView.setLayoutManager(layoutManager);
AddPlaylistAdapter adapter = new AddPlaylistAdapter(playlists);
recyclerView.setAdapter(adapter);
// setItemDecoration();
return view;
}
Aggregations