Move MENU_CLEAR_QUEUE action to PlaybackActivity and make ShowQueueActivity extend it
This commit is contained in:
parent
3a3530fc93
commit
c3bcc48d3c
@ -381,9 +381,6 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
case MENU_ENQUEUE_GENRE:
|
||||
PlaybackService.get(this).enqueueFromCurrent(MediaUtils.TYPE_GENRE);
|
||||
break;
|
||||
case MENU_CLEAR_QUEUE:
|
||||
PlaybackService.get(this).clearQueue();
|
||||
break;
|
||||
case MENU_SONG_FAVORITE:
|
||||
PlaybackService psvc = PlaybackService.get(this);
|
||||
ContentResolver resolver = getContentResolver();
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2010, 2011 Christopher Eby <kreed@kreed.org>
|
||||
*
|
||||
* Copyright (C) 2014 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
@ -327,6 +328,13 @@ public abstract class PlaybackActivity extends Activity
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the timeline change has changed.
|
||||
*/
|
||||
public void onTimelineChanged()
|
||||
{
|
||||
}
|
||||
|
||||
static final int MENU_SORT = 1;
|
||||
static final int MENU_PREFS = 2;
|
||||
static final int MENU_LIBRARY = 3;
|
||||
@ -338,6 +346,7 @@ public abstract class PlaybackActivity extends Activity
|
||||
static final int MENU_CLEAR_QUEUE = 11;
|
||||
static final int MENU_SONG_FAVORITE = 12;
|
||||
static final int MENU_SHOW_QUEUE = 13;
|
||||
static final int MENU_SAVEAS_PLAYLIST = 14;
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu)
|
||||
@ -352,10 +361,14 @@ public abstract class PlaybackActivity extends Activity
|
||||
switch (item.getItemId()) {
|
||||
case MENU_PREFS:
|
||||
startActivity(new Intent(this, PreferencesActivity.class));
|
||||
return true;
|
||||
break;
|
||||
case MENU_CLEAR_QUEUE:
|
||||
PlaybackService.get(this).clearQueue();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -268,10 +268,6 @@ public final class PlaybackService extends Service
|
||||
* Static referenced-array to PlaybackActivities, used for callbacks
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -1660,9 +1656,9 @@ public final class PlaybackService extends Service
|
||||
mHandler.removeMessages(GAPLESS_UPDATE);
|
||||
mHandler.sendEmptyMessageDelayed(GAPLESS_UPDATE, 350);
|
||||
|
||||
if (sShowQueueActivity != null)
|
||||
sShowQueueActivity.refreshSongQueueList(false);
|
||||
|
||||
ArrayList<PlaybackActivity> list = sActivities;
|
||||
for (int i = list.size(); --i != -1; )
|
||||
list.get(i).onTimelineChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1731,14 +1727,6 @@ public final class PlaybackService extends Service
|
||||
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
|
||||
* song timeline.
|
||||
|
@ -22,6 +22,7 @@ import java.util.Arrays;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
@ -29,7 +30,7 @@ import android.widget.AdapterView.OnItemLongClickListener;
|
||||
import android.widget.ListView;
|
||||
import com.mobeta.android.dslv.DragSortListView;
|
||||
|
||||
public class ShowQueueActivity extends Activity {
|
||||
public class ShowQueueActivity extends PlaybackActivity {
|
||||
private DragSortListView mListView;
|
||||
private ShowQueueAdapter listAdapter;
|
||||
private PlaybackService mService;
|
||||
@ -49,8 +50,6 @@ public class ShowQueueActivity extends Activity {
|
||||
mListView.setDropListener(onDrop);
|
||||
mListView.setRemoveListener(onRemove);
|
||||
|
||||
PlaybackService.addActivity(this);
|
||||
|
||||
mListView.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
@ -65,17 +64,32 @@ public class ShowQueueActivity extends Activity {
|
||||
}});
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
** Called when the user hits the ActionBar item
|
||||
** There is only one item (title) and it should quit this activity
|
||||
*/
|
||||
|
||||
/**
|
||||
* Inflate the ActionBar menu
|
||||
*/
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
finish();
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu.add(0, MENU_CLEAR_QUEUE, 0, R.string.clear_queue).setIcon(R.drawable.ic_menu_close_clear_cancel);
|
||||
menu.add(0, MENU_SAVEAS_PLAYLIST, 0, R.string.save_as_playlist).setIcon(R.drawable.ic_menu_preferences);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called after the user selected an action from the ActionBar
|
||||
*
|
||||
* @param item The selected menu item
|
||||
*/
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Called when we are displayed (again)
|
||||
** This will always refresh the whole song list
|
||||
@ -86,12 +100,6 @@ public class ShowQueueActivity extends Activity {
|
||||
refreshSongQueueList(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
PlaybackService.removeActivity(this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired from adapter listview if user moved an item
|
||||
* @param from the item index that was dragged
|
||||
@ -119,6 +127,12 @@ public class ShowQueueActivity extends Activity {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when the song timeline has changed
|
||||
*/
|
||||
public void onTimelineChanged() {
|
||||
refreshSongQueueList(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a refresh of the queueview
|
||||
|
Loading…
x
Reference in New Issue
Block a user