Android Open Source - kure-music-player Activity List Songs






From Project

Back to project page kure-music-player.

License

The source code is released under:

GNU General Public License

If you think the Android project kure-music-player listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.kure.musicplayer.activities;
/*from   ww w.  jav a2  s .  co m*/
import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ListView;

import com.kure.musicplayer.R;
import com.kure.musicplayer.kMP;
import com.kure.musicplayer.adapters.AdapterSong;


/**
 * Shows a predefined list of songs, letting the user select
 * them to play.
 *
 * @note This class is a mess because, to decide which songs to
 *       display, it uses the member `kMP.musicList`.
 */
public class ActivityListSongs extends ActivityMaster
  implements OnItemClickListener {

  /**
   * List of songs that will be shown to the user.
   */
  private ListView songListView;

  @Override
  protected void onCreate(Bundle popcorn) {
    super.onCreate(popcorn);

    setContentView(R.layout.activity_list_songs);

    // Let's fill ourselves with all the songs
    // available on the device.
    songListView = (ListView)findViewById(R.id.activity_list_songs_list);

    // We'll get warned when the user clicks on an item.
    songListView.setOnItemClickListener(this);

    // If we got an extra with a title, we'll apply it
    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();

    if (bundle != null)
      this.setTitle((String)bundle.get("title"));

    // Connects the song list to an adapter
    // (thing that creates several Layouts from the song list)
    if ((kMP.musicList != null) && (! kMP.musicList.isEmpty())) {
      AdapterSong songAdapter = new AdapterSong(this, kMP.musicList);
      songListView.setAdapter(songAdapter);
    }

    // This enables the "Up" button on the top Action Bar
    // Note that it returns to the parent Activity, specified
    // on `AndroidManifest`
    ActionBar actionBar = getActionBar();
    if (actionBar != null)
      actionBar.setDisplayHomeAsUpEnabled(true);

    // If we press and hold on a Song, let's add to the current
    // playing queue.
    songListView.setOnItemLongClickListener(new OnItemLongClickListener() {

      @Override
      public boolean onItemLongClick(AdapterView<?> parent, View view,
          int position, long id) {

        kMP.musicService.add(kMP.musicList.get(position));
        return true;
      }
    });

  }

  /**
   * When the user selects an item from our list, we'll start playing.
   *
   * We'll play the current list, starting from the song the user
   * just selected.
   */
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    // We'll play the current song list
    kMP.nowPlayingList = kMP.musicList;

    // Sending the song index inside the now playing list.
    // See the documentation of `ActivityNowPLaying` class.
    Intent intent = new Intent(this, ActivityNowPlaying.class);

    intent.putExtra("song", position);

    startActivity(intent);
  }
}




Java Source Code List

com.kure.musicplayer.MusicController.java
com.kure.musicplayer.NotificationMusic.java
com.kure.musicplayer.NotificationSimple.java
com.kure.musicplayer.Settings.java
com.kure.musicplayer.activities.ActivityListAlbums.java
com.kure.musicplayer.activities.ActivityListSongs.java
com.kure.musicplayer.activities.ActivityMaster.java
com.kure.musicplayer.activities.ActivityMenuAlbum.java
com.kure.musicplayer.activities.ActivityMenuArtist.java
com.kure.musicplayer.activities.ActivityMenuGenre.java
com.kure.musicplayer.activities.ActivityMenuMain.java
com.kure.musicplayer.activities.ActivityMenuMusic.java
com.kure.musicplayer.activities.ActivityMenuPlaylist.java
com.kure.musicplayer.activities.ActivityMenuSettings.java
com.kure.musicplayer.activities.ActivityMenuYear.java
com.kure.musicplayer.activities.ActivityNowPlaying.java
com.kure.musicplayer.activities.ActivityQuit.java
com.kure.musicplayer.activities.XXX.java
com.kure.musicplayer.adapters.AdapterSong.java
com.kure.musicplayer.external.RemoteControlClientCompat.java
com.kure.musicplayer.external.RemoteControlHelper.java
com.kure.musicplayer.helpers.SingleToast.java
com.kure.musicplayer.model.Playlist.java
com.kure.musicplayer.model.SongList.java
com.kure.musicplayer.model.Song.java
com.kure.musicplayer.services.ServicePlayMusic.java
com.kure.musicplayer.services.ServiceScrobbleMusic.java
com.kure.musicplayer.kMP.java