Commit b9a0eab8 authored by Sébastien Toque's avatar Sébastien Toque
Browse files

show current playlist by clicking on text in AudioPlayerActivity

parent a58fd0fc
......@@ -4,6 +4,20 @@
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/header_layout"
android:layout_width="fill_parent"
android:layout_height="48dip"
android:background="@drawable/header"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:scaleType="centerInside"
android:src="@drawable/header_logo" />
</LinearLayout>
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
......
......@@ -105,7 +105,9 @@
android:singleLine="true"
android:ellipsize="marquee"
android:layout_marginBottom="4dip"
android:id="@+id/title" />
android:id="@+id/title"
android:clickable="true"
android:onClick="onTextClick" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
......@@ -117,7 +119,9 @@
android:singleLine="true"
android:ellipsize="marquee"
android:layout_marginBottom="4dip"
android:id="@+id/artist" />
android:id="@+id/artist"
android:clickable="true"
android:onClick="onTextClick" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
......@@ -128,7 +132,9 @@
android:paddingRight="20dip"
android:singleLine="true"
android:ellipsize="marquee"
android:id="@+id/album" />
android:id="@+id/album"
android:clickable="true"
android:onClick="onTextClick" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
......
......@@ -124,6 +124,7 @@ public class AudioBrowserActivity extends Activity {
public void onItemClick(AdapterView<?> av, View v, int p, long id) {
mAudioController.load(mSongsAdapter.getPaths(), p);
Intent intent = new Intent(AudioBrowserActivity.this, AudioPlayerActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
};
......@@ -195,6 +196,7 @@ public class AudioBrowserActivity extends Activity {
mAudioController.load(medias, start_position);
Intent intent = new Intent(AudioBrowserActivity.this, AudioPlayerActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
return super.onContextItemSelected(item);
}
......
......@@ -46,6 +46,7 @@ public class AudioListActivity extends ListActivity {
private AudioServiceController mAudioController;
private MediaLibrary mMediaLibrary;
private View mHeader;
private TextView mTitle;
private AudioSongsListAdapter mSongsAdapter;
......@@ -66,6 +67,7 @@ public class AudioListActivity extends ListActivity {
mMediaLibrary = MediaLibrary.getInstance(this);
mMediaLibrary.addUpdateHandler(mHandler);
mHeader = (View) findViewById(R.id.header_layout);
mTitle = (TextView) findViewById(R.id.title);
mSongsAdapter = new AudioSongsListAdapter(this, R.layout.audio_browser_item);
......@@ -84,6 +86,7 @@ public class AudioListActivity extends ListActivity {
protected void onListItemClick(ListView l, View v, int position, long id) {
mAudioController.load(mSongsAdapter.getPaths(), position);
Intent intent = new Intent(AudioListActivity.this, AudioPlayerActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
super.onListItemClick(l, v, position, id);
}
......@@ -123,6 +126,7 @@ public class AudioListActivity extends ListActivity {
mAudioController.load(medias, start_position);
Intent intent = new Intent(AudioListActivity.this, AudioPlayerActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
return super.onContextItemSelected(item);
}
......@@ -169,13 +173,22 @@ public class AudioListActivity extends ListActivity {
private void updateList() {
String name = getIntent().getStringExtra(EXTRA_NAME);
int mode = getIntent().getIntExtra(EXTRA_MODE, 0);
if (name == null || mode == 0)
return;
List<Media> audioList;
List<String> itemList;
if (name == null || mode == 0) {
mHeader.setVisibility(View.VISIBLE);
mTitle.setText(R.string.songs);
itemList = AudioServiceController.getInstance().getItems();
audioList = MediaLibrary.getInstance(this).getMediaItems(itemList);
}
else {
mHeader.setVisibility(View.GONE);
mTitle.setText(name);
audioList = MediaLibrary.getInstance(this).getAudioItems(name, mode);
}
mTitle.setText(name);
List<Media> audioList = MediaLibrary.getInstance(this).getAudioItems(name, mode);
mSongsAdapter.clear();
switch (mSortBy) {
case SORT_BY_LENGTH:
Collections.sort(audioList, byLength);
......
......@@ -21,6 +21,7 @@
package org.videolan.vlc.android;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.media.AudioManager;
import android.os.Bundle;
......@@ -187,6 +188,12 @@ public class AudioPlayerActivity extends Activity implements AudioPlayer {
mShowRemainingTime = !mShowRemainingTime;
}
public void onTextClick(View view) {
Intent intent = new Intent(this, AudioListActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
public void onPlayPauseClick(View view) {
if (mAudioController.isPlaying()) {
mAudioController.pause();
......
......@@ -480,6 +480,15 @@ public class AudioService extends Service {
}
}
public List<String> getItems() {
ArrayList<String> medias = new ArrayList<String>();
for (int i = 0; i < mMediaList.size(); i++) {
Media item = mMediaList.get(i);
medias.add(item.getPath());
}
return medias;
}
@Override
public void next() throws RemoteException {
AudioService.this.next();
......
......@@ -113,6 +113,15 @@ public class AudioServiceController implements AudioPlayerControl {
}
}
public List<String> getItems() {
try {
return mAudioServiceBinder.getItems();
} catch (RemoteException e) {
Log.e(TAG, "remote procedure call failed: getItems()");
}
return new ArrayList<String>();
}
/**
* Bind to audio service if it is running
*/
......
......@@ -32,6 +32,7 @@ interface IAudioService {
String getCurrentMediaPath();
void load(in List<String> mediaPathList, int position);
void append(in List<String> mediaPathList);
List<String> getItems();
boolean isPlaying();
boolean isShuffling();
int getRepeatType();
......
......@@ -139,6 +139,15 @@ public class MediaLibrary {
return null;
}
public ArrayList<Media> getMediaItems(List<String> pathList) {
ArrayList<Media> items = new ArrayList<Media>();
for (int i = 0; i < pathList.size(); i++) {
Media item = getMediaItem(pathList.get(i));
items.add(item);
}
return items;
}
private final Runnable mGetMediaItems = new Runnable() {
private Stack<File> directorys = new Stack<File>();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment