use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.
the class PlayingActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// handle item selection
if (item.getItemId() == R.id.menu_share) {
MusicInfo musicInfo = MusicUtils.getMusicInfo(PlayingActivity.this, MusicPlayer.getCurrentAudioId());
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + musicInfo.data));
shareIntent.setType("audio/*");
this.startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.shared_to)));
}
return super.onOptionsItemSelected(item);
}
use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.
the class LocalSearchActivity method onQueryTextChange.
@Override
public boolean onQueryTextChange(final String newText) {
if (newText.equals(queryString)) {
return true;
}
queryString = newText;
if (!queryString.trim().equals("")) {
this.searchResults = new ArrayList();
List<MusicInfo> songList = SearchUtils.searchSongs(this, queryString);
searchResults.addAll((songList.size() < 10 ? songList : songList.subList(0, 10)));
} else {
searchResults.clear();
adapter.updateSearchResults(searchResults);
adapter.notifyDataSetChanged();
}
adapter.updateSearchResults(searchResults);
adapter.notifyDataSetChanged();
return true;
}
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 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());
}
}
Aggregations