Skip to content

Commit

Permalink
Previous list function implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
thalesalexcin committed Jun 20, 2012
1 parent 2231391 commit ec658d5
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 1 deletion.
Binary file added res/drawable-land-mdpi/player_prev_list_light.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/player_prev_list_light.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions res/layout-hdpi/player.xml
Expand Up @@ -120,6 +120,11 @@
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_marginBottom="10dip"
android:layout_alignParentBottom="true" android:visibility="gone"></ImageButton>
<ImageButton android:id="@+id/PrevListImageButton"
android:background="@null" android:src="@drawable/player_prev_list_light"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_marginBottom="10dip" android:layout_marginLeft="10dip"
android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" android:visibility="gone"></ImageButton>
<ImageButton android:id="@+id/NextImageButton"
android:background="@null" android:src="@drawable/player_next_light"
android:layout_width="wrap_content" android:layout_height="wrap_content"
Expand Down
7 changes: 7 additions & 0 deletions res/layout-land-hdpi/player.xml
Expand Up @@ -65,6 +65,13 @@
android:text="Artist" />
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_centerHorizontal="true"
android:layout_above="@id/ShuffleImageButton" android:layout_marginTop="70dip">
<ImageButton android:id="@+id/PrevListImageButton"
android:background="@null" android:src="@drawable/player_prev_list_light"
android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageButton>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true" android:layout_marginBottom="70dip" >
Expand Down
8 changes: 8 additions & 0 deletions res/layout-land-mdpi/player.xml
Expand Up @@ -73,6 +73,13 @@
android:layout_height="fill_parent">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_centerHorizontal="true"
android:layout_above="@id/ShuffleImageButton" android:layout_marginTop="70dip">
<ImageButton android:id="@+id/PrevListImageButton"
android:background="@null" android:src="@drawable/player_prev_list_light"
android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageButton>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true" android:layout_marginBottom="70dip" >
<ImageButton android:id="@+id/ShuffleImageButton"
android:background="@null" android:src="@drawable/player_shuffle_off"
Expand All @@ -82,6 +89,7 @@
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="2dip"></ImageButton>
</LinearLayout>

</RelativeLayout>
</LinearLayout>

Expand Down
5 changes: 5 additions & 0 deletions res/layout-mdpi/player.xml
Expand Up @@ -123,6 +123,11 @@
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_marginBottom="10dip"
android:layout_alignParentBottom="true" android:visibility="gone"></ImageButton>
<ImageButton android:id="@+id/PrevListImageButton"
android:background="@null" android:src="@drawable/player_prev_list_light"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_marginBottom="10dip" android:layout_marginLeft="10dip"
android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" android:visibility="gone"></ImageButton>
<ImageButton android:id="@+id/NextImageButton"
android:background="@null" android:src="@drawable/player_next_light"
android:layout_width="wrap_content" android:layout_height="wrap_content"
Expand Down
8 changes: 8 additions & 0 deletions src/com/teleca/jamendo/JamendoApplication.java
Expand Up @@ -357,6 +357,14 @@ public void rewind(int time) {
}

}

@Override
public void prevList() {
if(mServicePlayerEngine != null){
mServicePlayerEngine.prevList();
}

}

}

Expand Down
20 changes: 20 additions & 0 deletions src/com/teleca/jamendo/activity/PlayerActivity.java
Expand Up @@ -109,6 +109,7 @@ private PlayerEngine getPlayerEngine(){
private ImageButton mNextImageButton;
private ImageButton mPrevImageButton;
private ImageButton mStopImageButton;
private ImageButton mPrevListImageButton;
private ImageButton mShuffleImageButton;
private ImageButton mRepeatImageButton;
private RemoteImageView mCoverImageView;
Expand Down Expand Up @@ -232,6 +233,9 @@ public void run() {
mStopImageButton = (ImageButton)findViewById(R.id.StopImageButton);
mStopImageButton.setOnClickListener(mStopOnClickListener);

mPrevListImageButton = (ImageButton)findViewById(R.id.PrevListImageButton);
mPrevListImageButton.setOnClickListener(mPrevListOnClickListener);

mShuffleImageButton = (ImageButton)findViewById(R.id.ShuffleImageButton);
mShuffleImageButton.setOnClickListener(mShuffleOnClickListener);

Expand Down Expand Up @@ -378,6 +382,7 @@ private void setMediaVisible(){
mNextImageButton.setVisibility(View.VISIBLE);
mPrevImageButton.setVisibility(View.VISIBLE);
mStopImageButton.setVisibility(View.VISIBLE);
mPrevListImageButton.setVisibility(View.VISIBLE);
mShuffleImageButton.setVisibility(View.VISIBLE);
mRepeatImageButton.setVisibility(View.VISIBLE);
}
Expand All @@ -390,6 +395,7 @@ private void setMediaGone(){
mNextImageButton.setVisibility(View.GONE);
mPrevImageButton.setVisibility(View.GONE);
mStopImageButton.setVisibility(View.GONE);
mPrevListImageButton.setVisibility(View.GONE);
mShuffleImageButton.setVisibility(View.GONE);
mRepeatImageButton.setVisibility(View.GONE);
}
Expand All @@ -402,6 +408,7 @@ private void setFadeOutAnimation(){
mNextImageButton.setAnimation(mFadeOutAnimation);
mPrevImageButton.setAnimation(mFadeOutAnimation);
mStopImageButton.setAnimation(mFadeOutAnimation);
mPrevListImageButton.setAnimation(mFadeOutAnimation);
mShuffleImageButton.setAnimation(mFadeOutAnimation);
mRepeatImageButton.setAnimation(mFadeOutAnimation);
}
Expand All @@ -414,6 +421,7 @@ private void setFadeInAnimation(){
mNextImageButton.setAnimation(mFadeInAnimation);
mPrevImageButton.setAnimation(mFadeInAnimation);
mStopImageButton.setAnimation(mFadeInAnimation);
mPrevListImageButton.setAnimation(mFadeInAnimation);
mShuffleImageButton.setAnimation(mFadeInAnimation);
mRepeatImageButton.setAnimation(mFadeInAnimation);
}
Expand Down Expand Up @@ -478,6 +486,18 @@ public void onClick(View v) {
}

};

/**
* previous list button action
*/
private OnClickListener mPrevListOnClickListener = new OnClickListener(){

@Override
public void onClick(View v) {
getPlayerEngine().prevList();
}

};

/**
* shuffle button action
Expand Down
5 changes: 5 additions & 0 deletions src/com/teleca/jamendo/media/PlayerEngine.java
Expand Up @@ -73,6 +73,11 @@ public interface PlayerEngine {
*/
public void prev();

/**
* Jump to the last playList
*/
public void prevList();

/**
* Skip to the track on the playlist
*
Expand Down
16 changes: 15 additions & 1 deletion src/com/teleca/jamendo/media/PlayerEngineImpl.java
Expand Up @@ -101,6 +101,10 @@ private class InternalMediaPlayer extends MediaPlayer {
*/
private Playlist mPlaylist = null;

/**
* Playlist of song played before
*/
private Playlist prevPlaylist = null;

/**
* Handler to the context thread
Expand Down Expand Up @@ -143,8 +147,10 @@ public void next() {

@Override
public void openPlaylist(Playlist playlist) {
if(!playlist.isEmpty())
if(!playlist.isEmpty()){
prevPlaylist = mPlaylist;
mPlaylist = playlist;
}
else
mPlaylist = null;
}
Expand Down Expand Up @@ -425,4 +431,12 @@ public void forward(int time) {
public void rewind(int time) {
mCurrentMediaPlayer.seekTo( mCurrentMediaPlayer.getCurrentPosition()-time );
}

@Override
public void prevList() {
if(prevPlaylist != null){
openPlaylist(prevPlaylist);
play();
}
}
}

0 comments on commit ec658d5

Please sign in to comment.