use of me.zhanghai.android.douya.network.api.info.frodo.Music in project Douya by DreaminginCodeZH.
the class ItemIntroductionActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Calls ensureSubDecor().
findViewById(android.R.id.content);
if (savedInstanceState == null) {
Intent intent = getIntent();
CollectableItem item = intent.getParcelableExtra(EXTRA_ITEM);
Fragment fragment;
switch(item.getType()) {
case APP:
// TODO
throw new UnsupportedOperationException();
case BOOK:
fragment = BookIntroductionFragment.newInstance((Book) item);
break;
case EVENT:
// TODO
throw new UnsupportedOperationException();
case GAME:
fragment = GameIntroductionFragment.newInstance((Game) item);
break;
case MOVIE:
case TV:
fragment = MovieIntroductionFragment.newInstance((Movie) item);
break;
case MUSIC:
fragment = MusicIntroductionFragment.newInstance((Music) item);
break;
default:
throw new IllegalArgumentException();
}
FragmentUtils.add(fragment, this, android.R.id.content);
}
}
use of me.zhanghai.android.douya.network.api.info.frodo.Music in project Douya by DreaminginCodeZH.
the class PlayMusicService method onHandleIntent.
private void onHandleIntent(Intent intent) {
Music music = intent.getParcelableExtra(EXTRA_MUSIC);
boolean hasTrackIndex = intent.hasExtra(EXTRA_TRACK_INDEX);
int trackIndex = intent.getIntExtra(EXTRA_TRACK_INDEX, 0);
boolean playOrPause = intent.getBooleanExtra(EXTRA_PLAY_OR_PAUSE, false);
boolean musicChanged = music.id != getMusicId();
mMusic = music;
if (musicChanged) {
mMediaPlayback.stop();
// TODO: Use dedicated session activity.
PendingIntent sessionActivity = PendingIntent.getActivity(this, LongCompat.hashCode(getMusicId()), MusicActivity.makeIntent(mMusic, this), PendingIntent.FLAG_UPDATE_CURRENT);
mMediaPlayback.setSessionActivity(sessionActivity);
List<MediaMetadataCompat> mediaMetadatas = Functional.map(mMusic.tracks, (track, index) -> makeMediaMetadata(mMusic, track, index));
mMediaPlayback.setMediaMetadatas(mediaMetadatas);
loadMediaMetadataDisplayIconAndAlbumArt(mMusic);
mMediaPlayback.start();
}
if (!hasTrackIndex) {
mMediaPlayback.skipToQueueItem(0);
mMediaPlayback.play();
} else {
if (mMediaPlayback.getActiveQueueItemIndex() != trackIndex) {
mMediaPlayback.skipToQueueItem(trackIndex);
}
if (playOrPause) {
mMediaPlayback.play();
} else {
mMediaPlayback.pause();
}
}
mMediaNotification.start();
}
use of me.zhanghai.android.douya.network.api.info.frodo.Music in project Douya by DreaminginCodeZH.
the class MusicFragment method uncollect.
@Override
public void uncollect() {
if (!mResource.hasItem()) {
return;
}
Music music = mResource.getItem();
UncollectItemManager.getInstance().write(music.getType(), music.id, getActivity());
}
use of me.zhanghai.android.douya.network.api.info.frodo.Music in project Douya by DreaminginCodeZH.
the class MusicActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Calls ensureSubDecor().
findViewById(android.R.id.content);
if (savedInstanceState == null) {
Intent intent = getIntent();
long musicId = intent.getLongExtra(EXTRA_MUSIC_ID, -1);
SimpleMusic simpleMusic = intent.getParcelableExtra(EXTRA_SIMPLE_MUSIC);
Music music = intent.getParcelableExtra(EXTRA_MUSIC);
FragmentUtils.add(MusicFragment.newInstance(musicId, simpleMusic, music), this, android.R.id.content);
}
}
Aggregations