propagate timeline changes to ShowQueue
This commit is contained in:
parent
12f2655ec8
commit
c92bc5a56e
@ -264,7 +264,14 @@ public final class PlaybackService extends Service
|
|||||||
* The appplication-wide instance of the PlaybackService.
|
* The appplication-wide instance of the PlaybackService.
|
||||||
*/
|
*/
|
||||||
public static PlaybackService sInstance;
|
public static PlaybackService sInstance;
|
||||||
|
/**
|
||||||
|
* Static referenced-array to PlaybackActivities, used for callbacks
|
||||||
|
*/
|
||||||
private static final ArrayList<PlaybackActivity> sActivities = new ArrayList<PlaybackActivity>(5);
|
private static final ArrayList<PlaybackActivity> sActivities = new ArrayList<PlaybackActivity>(5);
|
||||||
|
/**
|
||||||
|
* Static reference to the ShowQueueActivity
|
||||||
|
*/
|
||||||
|
private static ShowQueueActivity sShowQueueActivity = null;
|
||||||
/**
|
/**
|
||||||
* Cached app-wide SharedPreferences instance.
|
* Cached app-wide SharedPreferences instance.
|
||||||
*/
|
*/
|
||||||
@ -1652,6 +1659,10 @@ public final class PlaybackService extends Service
|
|||||||
// to processSong();
|
// to processSong();
|
||||||
mHandler.removeMessages(GAPLESS_UPDATE);
|
mHandler.removeMessages(GAPLESS_UPDATE);
|
||||||
mHandler.sendEmptyMessageDelayed(GAPLESS_UPDATE, 350);
|
mHandler.sendEmptyMessageDelayed(GAPLESS_UPDATE, 350);
|
||||||
|
|
||||||
|
if (sShowQueueActivity != null)
|
||||||
|
sShowQueueActivity.refreshSongQueueList(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1720,6 +1731,14 @@ public final class PlaybackService extends Service
|
|||||||
sActivities.remove(activity);
|
sActivities.remove(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addActivity(ShowQueueActivity activity) {
|
||||||
|
sShowQueueActivity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeActivity(ShowQueueActivity activity) {
|
||||||
|
sShowQueueActivity = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the service state, loading songs saved from the disk into the
|
* Initializes the service state, loading songs saved from the disk into the
|
||||||
* song timeline.
|
* song timeline.
|
||||||
|
@ -50,6 +50,8 @@ public class ShowQueueActivity
|
|||||||
mListView.setFastScrollAlwaysVisible(true);
|
mListView.setFastScrollAlwaysVisible(true);
|
||||||
mListView.setEditable(true);
|
mListView.setEditable(true);
|
||||||
|
|
||||||
|
PlaybackService.addActivity(this);
|
||||||
|
|
||||||
mListView.setOnItemClickListener(new OnItemClickListener() {
|
mListView.setOnItemClickListener(new OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
@ -60,10 +62,6 @@ public class ShowQueueActivity
|
|||||||
@Override
|
@Override
|
||||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
mService.jumpToQueuePosition(position);
|
mService.jumpToQueuePosition(position);
|
||||||
/* This activity will stay open on longpress, so we have
|
|
||||||
* to update the playmerker ourselfs */
|
|
||||||
listAdapter.highlightRow(position);
|
|
||||||
listAdapter.notifyDataSetChanged();
|
|
||||||
return true;
|
return true;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@ -89,6 +87,12 @@ public class ShowQueueActivity
|
|||||||
refreshSongQueueList(true);
|
refreshSongQueueList(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
PlaybackService.removeActivity(this);
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired from adapter list if user moved an item
|
* Fired from adapter list if user moved an item
|
||||||
* @param from the item index that was dragged
|
* @param from the item index that was dragged
|
||||||
@ -96,23 +100,30 @@ public class ShowQueueActivity
|
|||||||
*/
|
*/
|
||||||
public void onItemMoved(int from, int to) {
|
public void onItemMoved(int from, int to) {
|
||||||
mService.moveSong(from, to);
|
mService.moveSong(from, to);
|
||||||
refreshSongQueueList(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshSongQueueList(boolean scroll) {
|
/**
|
||||||
int i, stotal, spos;
|
* Triggers a refresh of the queueview
|
||||||
|
* @param scroll enable or disable jumping to the currently playing item
|
||||||
|
*/
|
||||||
|
public void refreshSongQueueList(final boolean scroll) {
|
||||||
|
runOnUiThread(new Runnable(){
|
||||||
|
public void run() {
|
||||||
|
int i, stotal, spos;
|
||||||
|
stotal = mService.getTimelineLength(); /* Total number of songs in queue */
|
||||||
|
spos = mService.getTimelinePosition(); /* Current position in queue */
|
||||||
|
|
||||||
stotal = mService.getTimelineLength(); /* Total number of songs in queue */
|
listAdapter.clear(); /* Flush all existing entries... */
|
||||||
spos = mService.getTimelinePosition(); /* Current position in queue */
|
listAdapter.highlightRow(spos); /* and highlight current position */
|
||||||
|
|
||||||
listAdapter.clear(); /* Flush all existing entries... */
|
for(i=0 ; i<stotal; i++) {
|
||||||
listAdapter.highlightRow(spos); /* and highlight current position */
|
listAdapter.add(mService.getSongByQueuePosition(i));
|
||||||
|
}
|
||||||
|
|
||||||
for(i=0 ; i<stotal; i++) {
|
if (scroll == true)
|
||||||
listAdapter.add(mService.getSongByQueuePosition(i));
|
mListView.setSelectionFromTop(spos, 0); /* scroll to currently playing song */
|
||||||
}
|
}
|
||||||
if (scroll == true)
|
});
|
||||||
mListView.setSelectionFromTop(spos, 0); /* scroll to currently playing song */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user