use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.
the class PlaylistDetailAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder itemHolder, final int i) {
if (itemHolder instanceof ItemViewHolder) {
MusicInfo localItem = arraylist.get(i - 1);
((ItemViewHolder) itemHolder).trackNumber.setText(i + "");
((ItemViewHolder) itemHolder).title.setText(localItem.musicName);
((ItemViewHolder) itemHolder).artist.setText(localItem.artist);
((ItemViewHolder) itemHolder).menu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MoreFragment morefragment = MoreFragment.newInstance(arraylist.get(i - 1).songId + "", IConstants.MUSICOVERFLOW);
morefragment.show(((AppCompatActivity) mContext).getSupportFragmentManager(), "music");
}
});
} else if (itemHolder instanceof CommonItemViewHolder) {
((CommonItemViewHolder) itemHolder).textView.setText("(共" + arraylist.size() + "首)");
((CommonItemViewHolder) itemHolder).select.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, PlaylistSelectActivity.class);
intent.putParcelableArrayListExtra("ids", arraylist);
intent.putExtra("playlistid", playlistId);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
mContext.startActivity(intent);
}
});
}
}
use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.
the class SearchAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
MusicInfo song = searchResults.get(i);
itemHolder.title.setText(song.musicName);
itemHolder.songartist.setText(song.artist);
setOnPopupMenuListener(itemHolder, i);
}
use of com.wm.remusic.info.MusicInfo 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.MusicInfo in project remusic by aa112901.
the class PlaylistsManager method insertLists.
public synchronized void insertLists(Context context, long playlistid, ArrayList<MusicInfo> musicInfos) {
final SQLiteDatabase database = mMusicDatabase.getWritableDatabase();
database.beginTransaction();
int len = musicInfos.size();
try {
for (int i = 0; i < len; i++) {
MusicInfo info = musicInfos.get(i);
ContentValues values = new ContentValues(11);
values.put(PlaylistsColumns.PLAYLIST_ID, playlistid);
values.put(PlaylistsColumns.TRACK_ID, info.songId);
values.put(PlaylistsColumns.TRACK_ORDER, getPlaylist(playlistid).size());
values.put(PlaylistsColumns.TRACK_NAME, info.musicName);
values.put(PlaylistsColumns.ALBUM_ID, info.albumId);
values.put(PlaylistsColumns.ALBUM_NAME, info.albumName);
values.put(PlaylistsColumns.ALBUM_ART, info.albumData);
values.put(PlaylistsColumns.ARTIST_NAME, info.artist);
values.put(PlaylistsColumns.ARTIST_ID, info.artistId);
values.put(PlaylistsColumns.PATH, info.data);
values.put(PlaylistsColumns.IS_LOCAL, info.islocal);
database.insertWithOnConflict(PlaylistsColumns.NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
}
database.setTransactionSuccessful();
} catch (Exception e) {
e.printStackTrace();
} finally {
database.endTransaction();
}
PlaylistInfo playlistInfo = PlaylistInfo.getInstance(context);
String albumart = null;
for (int i = len - 1; i >= 0; i--) {
MusicInfo info = musicInfos.get(i);
albumart = info.albumData;
if (info.islocal) {
String art = MusicUtils.getAlbumdata(MainApplication.context, info.songId);
if (art != null) {
break;
} else {
albumart = null;
}
} else if (!albumart.isEmpty()) {
break;
}
}
if (albumart != null) {
playlistInfo.update(playlistid, getPlaylist(playlistid).size(), albumart);
} else {
playlistInfo.update(playlistid, getPlaylist(playlistid).size());
}
}
use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.
the class PlaylistsManager method getMusicInfos.
public ArrayList<MusicInfo> getMusicInfos(final long playlistid) {
ArrayList<MusicInfo> results = new ArrayList<>();
Cursor cursor = null;
try {
cursor = mMusicDatabase.getReadableDatabase().query(PlaylistsColumns.NAME, null, PlaylistsColumns.PLAYLIST_ID + " = " + String.valueOf(playlistid), null, null, null, PlaylistsColumns.TRACK_ORDER + " ASC ", null);
if (cursor != null && cursor.moveToFirst()) {
results.ensureCapacity(cursor.getCount());
do {
MusicInfo info = new MusicInfo();
info.songId = cursor.getLong(1);
info.musicName = cursor.getString(2);
info.albumId = cursor.getInt(3);
info.albumName = cursor.getString(4);
info.albumData = cursor.getString(5);
info.artistId = cursor.getLong(6);
info.artist = cursor.getString(7);
info.islocal = cursor.getInt(8) > 0;
results.add(info);
} while (cursor.moveToNext());
}
return results;
} finally {
if (cursor != null) {
cursor.close();
cursor = null;
}
}
}
Aggregations