Added menu item to clear the queue
This commit is contained in:
parent
870b673527
commit
2c9a5ff54e
|
@ -4,5 +4,6 @@
|
|||
<item name="action_bar_add" type="id"/>
|
||||
<item name="move_up_item" type="id"/>
|
||||
<item name="move_down_item" type="id"/>
|
||||
<item type="id" name="clear_queue_item"/>
|
||||
|
||||
</resources>
|
|
@ -96,5 +96,6 @@
|
|||
<string name="external_storage_error_msg">No external storage is available. Please make sure that external storage is mounted so that the app can work properly.</string>
|
||||
<string name="share_link_label">Share link...</string>
|
||||
<string name="share_source_label">Share source link...</string>
|
||||
<string name="clear_queue_label">Clear queue</string>
|
||||
|
||||
</resources>
|
|
@ -241,6 +241,17 @@ public class FeedManager {
|
|||
sendQueueUpdateBroadcast(context, item);
|
||||
}
|
||||
|
||||
/** Removes all items in queue */
|
||||
public void clearQueue(Context context) {
|
||||
Log.d(TAG, "Clearing queue");
|
||||
PodDBAdapter adapter = new PodDBAdapter(context);
|
||||
adapter.open();
|
||||
queue.clear();
|
||||
adapter.setQueue(queue);
|
||||
adapter.close();
|
||||
sendQueueUpdateBroadcast(context, null);
|
||||
}
|
||||
|
||||
/** Uses external adapter. */
|
||||
public void removeQueueItem(FeedItem item, PodDBAdapter adapter) {
|
||||
boolean removed = queue.remove(item);
|
||||
|
|
|
@ -4,9 +4,11 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.actionbarsherlock.view.ActionMode;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import de.podfetcher.R;
|
||||
|
@ -45,6 +47,12 @@ public class QueueFragment extends ItemlistFragment {
|
|||
new IntentFilter(FeedManager.ACTION_QUEUE_UPDATE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
boolean handled = false;
|
||||
|
@ -74,4 +82,23 @@ public class QueueFragment extends ItemlistFragment {
|
|||
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
menu.add(Menu.NONE, R.id.clear_queue_item, Menu.NONE, getActivity()
|
||||
.getString(R.string.clear_queue_label));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.clear_queue_item:
|
||||
manager.clearQueue(getActivity());
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue