Methods Summary |
---|
private void | doAutoShuffle()
bindService((new Intent()).setClass(this, MediaPlaybackService.class), autoshuffle, 0);
|
public void | init()
setContentView(R.layout.music_library);
mNowPlayingView = findViewById(R.id.nowplaying);
mTitle = (TextView) mNowPlayingView.findViewById(R.id.title);
mArtist = (TextView) mNowPlayingView.findViewById(R.id.artist);
View b = (View) findViewById(R.id.browse_button);
b.setOnClickListener(this);
b = (View) findViewById(R.id.albums_button);
b.setOnClickListener(this);
b = (View) findViewById(R.id.tracks_button);
b.setOnClickListener(this);
b = (View) findViewById(R.id.playlists_button);
b.setOnClickListener(this);
|
private void | makeNowPlayingView()
try {
mTitle.setText(MusicUtils.sService.getTrackName());
String artistName = MusicUtils.sService.getArtistName();
if (MediaFile.UNKNOWN_STRING.equals(artistName)) {
artistName = getString(R.string.unknown_artist_name);
}
mArtist.setText(artistName);
mNowPlayingView.setOnFocusChangeListener(mFocuser);
mNowPlayingView.setOnClickListener(this);
} catch (RemoteException ex) {
}
|
public void | onClick(android.view.View v)
Intent intent;
switch (v.getId()) {
case R.id.browse_button:
intent = new Intent(Intent.ACTION_PICK);
intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/artistalbum");
startActivity(intent);
break;
case R.id.albums_button:
intent = new Intent(Intent.ACTION_PICK);
intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/album");
startActivity(intent);
break;
case R.id.tracks_button:
intent = new Intent(Intent.ACTION_PICK);
intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
startActivity(intent);
break;
case R.id.playlists_button:
intent = new Intent(Intent.ACTION_PICK);
intent.setDataAndType(Uri.EMPTY, MediaStore.Audio.Playlists.CONTENT_TYPE);
startActivity(intent);
break;
case R.id.nowplaying:
intent = new Intent("com.android.music.PLAYBACK_VIEWER");
startActivity(intent);
break;
}
|
public void | onCreate(android.os.Bundle icicle)Called when the activity is first created.
super.onCreate(icicle);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
String shuf = getIntent().getStringExtra("autoshuffle");
if ("true".equals(shuf)) {
mAutoShuffle = true;
}
MusicUtils.bindToService(this, new ServiceConnection() {
public void onServiceConnected(ComponentName classname, IBinder obj) {
updateMenu();
}
public void onServiceDisconnected(ComponentName classname) {
updateMenu();
}
});
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
init();
|
public boolean | onCreateOptionsMenu(android.view.Menu menu)
super.onCreateOptionsMenu(menu);
menu.add(0, PARTY_SHUFFLE, 0, R.string.party_shuffle); // icon will be set in onPrepareOptionsMenu()
menu.add(0, SEARCH_MUSIC, 0, R.string.search_title).setIcon(android.R.drawable.ic_menu_search);
return true;
|
public void | onDestroy()
MusicUtils.unbindFromService(this);
super.onDestroy();
|
public boolean | onOptionsItemSelected(android.view.MenuItem item)
Intent intent;
try {
switch (item.getItemId()) {
case PARTY_SHUFFLE:
int shuffle = MusicUtils.sService.getShuffleMode();
if (shuffle == MediaPlaybackService.SHUFFLE_AUTO) {
MusicUtils.sService.setShuffleMode(MediaPlaybackService.SHUFFLE_NONE);
} else {
MusicUtils.sService.setShuffleMode(MediaPlaybackService.SHUFFLE_AUTO);
}
break;
case SEARCH_MUSIC: {
startSearch("", false, null, false);
return true;
}
}
} catch (RemoteException ex) {
}
return super.onOptionsItemSelected(item);
|
public void | onPause()
super.onPause();
unregisterReceiver(mStatusListener);
|
public boolean | onPrepareOptionsMenu(android.view.Menu menu)
MenuItem item = menu.findItem(PARTY_SHUFFLE);
if (item != null) {
int shuffle = MusicUtils.getCurrentShuffleMode();
if (shuffle == MediaPlaybackService.SHUFFLE_AUTO) {
item.setIcon(R.drawable.ic_menu_party_shuffle);
item.setTitle(R.string.party_shuffle_off);
} else {
item.setIcon(R.drawable.ic_menu_party_shuffle);
item.setTitle(R.string.party_shuffle);
}
}
return true;
|
public void | onResume()
super.onResume();
IntentFilter f = new IntentFilter();
f.addAction(MediaPlaybackService.META_CHANGED);
registerReceiver(mStatusListener, new IntentFilter(f));
updateMenu();
if (mAutoShuffle) {
mAutoShuffle = false;
doAutoShuffle();
}
|
private void | updateMenu()
try {
if (MusicUtils.sService != null && MusicUtils.sService.getAudioId() != -1) {
makeNowPlayingView();
mNowPlayingView.setVisibility(View.VISIBLE);
return;
}
} catch (RemoteException ex) {
}
mNowPlayingView.setVisibility(View.INVISIBLE);
|