use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.
the class PlaylistActivity method setHeaderView.
private void setHeaderView() {
albumArt = (ImageView) findViewById(R.id.album_art);
playlistTitleView = (TextView) findViewById(R.id.album_title);
playlistDetailView = (TextView) findViewById(R.id.album_details);
albumArtSmall = (SimpleDraweeView) findViewById(R.id.playlist_art);
SpannableString spanString;
Bitmap b = BitmapFactory.decodeResource(getResources(), R.mipmap.index_icn_earphone);
ImageSpan imgSpan = new ImageSpan(this, b, ImageSpan.ALIGN_BASELINE);
spanString = new SpannableString("icon");
spanString.setSpan(imgSpan, 0, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
playlistCountView = (TextView) findViewById(R.id.playlist_listen_count);
playlistCountView.setText(spanString);
if (playlistCount == null) {
playlistCount = "0";
}
int count = Integer.parseInt(playlistCount);
if (count > 10000) {
count = count / 10000;
playlistCountView.append(" " + count + "万");
} else {
playlistCountView.append(" " + playlistCount);
}
LinearLayout downAll = (LinearLayout) headerViewContent.findViewById(R.id.playlist_down);
downAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new LoadAllDownInfos((Activity) mContext, mList).execute();
}
});
final LinearLayout addToplaylist = (LinearLayout) headerViewContent.findViewById(R.id.playlist_collect);
addToplaylist.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mCollected) {
collectText.setText("已收藏");
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
String albumart = null;
for (MusicInfo info : adapterList) {
albumart = info.albumData;
if (!TextUtils.isEmpty(albumart)) {
break;
}
}
PlaylistInfo.getInstance(mContext).addPlaylist(Long.parseLong(playlsitId), playlistName, adapterList.size(), albumart, "net");
PlaylistsManager.getInstance(mContext).insertLists(mContext, Long.parseLong(playlsitId), adapterList);
Intent intent = new Intent(IConstants.PLAYLIST_COUNT_CHANGED);
MainApplication.context.sendBroadcast(intent);
mCollected = true;
return null;
}
}.execute();
} else {
collectText.setText("收藏");
PlaylistInfo.getInstance(mContext).deletePlaylist(Long.parseLong(playlsitId));
mCollected = false;
}
}
});
share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("http://music.baidu.com/songlist/" + playlsitId));
shareIntent.setType("html/*");
startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.shared_to)));
}
});
if (!isLocalPlaylist)
headerDetail.setVisibility(View.GONE);
tryAgain.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loadAllLists();
}
});
if (Integer.parseInt(playlsitId) == IConstants.FAV_PLAYLIST) {
favLayout.setVisibility(View.VISIBLE);
}
}
use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.
the class LockActivity method onClick.
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.lock_music_pre:
MusicPlayer.previous(this, true);
break;
case R.id.lock_music_play:
MusicPlayer.playOrPause();
break;
case R.id.lock_music_next:
MusicPlayer.next();
break;
case R.id.lock_music_fav:
if (isFav) {
playlistsManager.removeItem(this, IConstants.FAV_PLAYLIST, MusicPlayer.getCurrentAudioId());
fav.setImageResource(R.drawable.lock_btn_love);
isFav = false;
} else {
try {
MusicInfo info = MusicPlayer.getPlayinfos().get(MusicPlayer.getCurrentAudioId());
playlistsManager.insertMusic(this, IConstants.FAV_PLAYLIST, info);
} catch (Exception e) {
e.printStackTrace();
}
fav.setImageResource(R.drawable.lock_btn_loved);
isFav = true;
}
break;
}
}
use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.
the class MediaService method reloadQueue.
private void reloadQueue() {
int id = mCardId;
if (mPreferences.contains("cardid")) {
id = mPreferences.getInt("cardid", ~mCardId);
}
if (id == mCardId) {
mPlaylist = mPlaybackStateStore.getQueue();
try {
FileInputStream in = new FileInputStream(new File(getCacheDir().getAbsolutePath() + "playlist"));
String c = readTextFromSDcard(in);
HashMap<Long, MusicInfo> play = MainApplication.gsonInstance().fromJson(c, new TypeToken<HashMap<Long, MusicInfo>>() {
}.getType());
if (play != null && play.size() > 0) {
mPlaylistInfo = play;
L.D(D, TAG, mPlaylistInfo.keySet().toString());
}
} catch (Exception e) {
e.printStackTrace();
}
}
if ((mPlaylist.size() == mPlaylistInfo.size()) && mPlaylist.size() > 0) {
final int pos = mPreferences.getInt("curpos", 0);
if (pos < 0 || pos >= mPlaylist.size()) {
mPlaylist.clear();
return;
}
mPlayPos = pos;
updateCursor(mPlaylist.get(mPlayPos).mId);
if (mCursor == null) {
SystemClock.sleep(3000);
updateCursor(mPlaylist.get(mPlayPos).mId);
}
synchronized (this) {
closeCursor();
mOpenFailedCounter = 20;
openCurrentAndNext();
}
// if (!mPlayer.isInitialized() && isTrackLocal()) {
// mPlaylist.clear();
// return;
// }
final long seekpos = mPreferences.getLong("seekpos", 0);
mLastSeekPos = seekpos;
seek(seekpos >= 0 && seekpos < duration() ? seekpos : 0);
if (D) {
Log.d(TAG, "restored queue, currently at position " + position() + "/" + duration() + " (requested " + seekpos + ")");
}
int repmode = mPreferences.getInt("repeatmode", REPEAT_ALL);
if (repmode != REPEAT_ALL && repmode != REPEAT_CURRENT) {
repmode = REPEAT_NONE;
}
mRepeatMode = repmode;
int shufmode = mPreferences.getInt("shufflemode", SHUFFLE_NONE);
if (shufmode != SHUFFLE_AUTO && shufmode != SHUFFLE_NORMAL) {
shufmode = SHUFFLE_NONE;
}
if (shufmode != SHUFFLE_NONE) {
mHistory = mPlaybackStateStore.getHistory(mPlaylist.size());
}
if (shufmode == SHUFFLE_AUTO) {
if (!makeAutoShuffleList()) {
shufmode = SHUFFLE_NONE;
}
}
mShuffleMode = shufmode;
} else {
clearPlayInfos();
}
notifyChange(MUSIC_CHANGED);
}
use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.
the class MediaService method updateCursor.
private void updateCursor(final long trackId) {
MusicInfo info = mPlaylistInfo.get(trackId);
if (mPlaylistInfo.get(trackId) != null) {
MatrixCursor cursor = new MatrixCursor(PROJECTION);
cursor.addRow(new Object[] { info.songId, info.artist, info.albumName, info.musicName, info.data, info.albumData, info.albumId, info.artistId });
cursor.moveToFirst();
mCursor = cursor;
cursor.close();
}
}
use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.
the class MusicUtils method queryMusic.
public static ArrayList<MusicInfo> queryMusic(Context context, String id, int from) {
Uri uri = Media.EXTERNAL_CONTENT_URI;
ContentResolver cr = context.getContentResolver();
StringBuilder select = new StringBuilder(" 1=1 and title != ''");
// 查询语句:检索出.mp3为后缀名,时长大于1分钟,文件大小大于1MB的媒体文件
select.append(" and " + Media.SIZE + " > " + FILTER_SIZE);
select.append(" and " + Media.DURATION + " > " + FILTER_DURATION);
String selectionStatement = "is_music=1 AND title != ''";
final String songSortOrder = PreferencesUtility.getInstance(context).getSongSortOrder();
switch(from) {
case START_FROM_LOCAL:
ArrayList<MusicInfo> list3 = getMusicListCursor(cr.query(uri, proj_music, select.toString(), null, songSortOrder));
return list3;
case START_FROM_ARTIST:
select.append(" and " + Media.ARTIST_ID + " = " + id);
return getMusicListCursor(cr.query(uri, proj_music, select.toString(), null, PreferencesUtility.getInstance(context).getArtistSongSortOrder()));
case START_FROM_ALBUM:
select.append(" and " + Media.ALBUM_ID + " = " + id);
return getMusicListCursor(cr.query(uri, proj_music, select.toString(), null, PreferencesUtility.getInstance(context).getAlbumSongSortOrder()));
case START_FROM_FOLDER:
ArrayList<MusicInfo> list1 = new ArrayList<>();
ArrayList<MusicInfo> list = getMusicListCursor(cr.query(Media.EXTERNAL_CONTENT_URI, proj_music, select.toString(), null, null));
for (MusicInfo music : list) {
if (music.data.substring(0, music.data.lastIndexOf(File.separator)).equals(id)) {
list1.add(music);
}
}
return list1;
default:
return null;
}
}
Aggregations