Don't autodownload episodes when item is removed from queue via

drag&drop
This commit is contained in:
daniel oeh 2013-04-20 11:03:31 +02:00
parent 5b4fde69de
commit 960dd3425f
4 changed files with 32 additions and 29 deletions

View File

@ -25,7 +25,8 @@ import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.preferences.UserPreferences;
import de.danoeh.antennapod.util.UndoBarController;
public class OrganizeQueueActivity extends SherlockListActivity implements UndoBarController.UndoListener {
public class OrganizeQueueActivity extends SherlockListActivity implements
UndoBarController.UndoListener {
private static final String TAG = "OrganizeQueueActivity";
private static final int MENU_ID_ACCEPT = 2;
@ -46,7 +47,8 @@ public class OrganizeQueueActivity extends SherlockListActivity implements UndoB
adapter = new OrganizeAdapter(this);
setListAdapter(adapter);
undoBarController = new UndoBarController(findViewById(R.id.undobar), this);
undoBarController = new UndoBarController(findViewById(R.id.undobar),
this);
}
@Override
@ -89,9 +91,10 @@ public class OrganizeQueueActivity extends SherlockListActivity implements UndoB
public void remove(int which) {
FeedManager manager = FeedManager.getInstance();
FeedItem item = (FeedItem) getListAdapter().getItem(which);
manager.removeQueueItem(OrganizeQueueActivity.this, item);
undoBarController.showUndoBar(false, getString(R.string.removed_from_queue),
new UndoToken(item, which));
manager.removeQueueItem(OrganizeQueueActivity.this, item, false);
undoBarController.showUndoBar(false,
getString(R.string.removed_from_queue), new UndoToken(item,
which));
}
};
@ -111,6 +114,8 @@ public class OrganizeQueueActivity extends SherlockListActivity implements UndoB
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_ID_ACCEPT:
FeedManager.getInstance().autodownloadUndownloadedItems(
getApplicationContext());
finish();
return true;
default:
@ -126,14 +131,10 @@ public class OrganizeQueueActivity extends SherlockListActivity implements UndoB
int position = undoToken.getPosition();
FeedManager manager = FeedManager.getInstance();
manager.addQueueItemAt(OrganizeQueueActivity.this, feedItem, position, false);
manager.addQueueItemAt(OrganizeQueueActivity.this, feedItem, position,
false);
}
/**
* WARNING: If the PlaybackService is playing an episode from the queue,
* this list adapter will ignore the first item in the list to make sure
* that the position of the first queue item cannot be changed.
*/
private static class OrganizeAdapter extends BaseAdapter {
private Context context;
@ -222,16 +223,15 @@ public class OrganizeQueueActivity extends SherlockListActivity implements UndoB
position = in.readInt();
}
public static final Parcelable.Creator<UndoToken> CREATOR
= new Parcelable.Creator<UndoToken>() {
public UndoToken createFromParcel(Parcel in) {
return new UndoToken(in);
}
public static final Parcelable.Creator<UndoToken> CREATOR = new Parcelable.Creator<UndoToken>() {
public UndoToken createFromParcel(Parcel in) {
return new UndoToken(in);
}
public UndoToken[] newArray(int size) {
return new UndoToken[size];
}
};
public UndoToken[] newArray(int size) {
return new UndoToken[size];
}
};
public int describeContents() {
return 0;

View File

@ -970,7 +970,8 @@ public class FeedManager {
}
/** Removes a FeedItem from the queue. */
public void removeQueueItem(final Context context, FeedItem item) {
public void removeQueueItem(final Context context, FeedItem item,
final boolean performAutoDownload) {
boolean removed = queue.remove(item);
if (removed) {
dbExec.execute(new Runnable() {
@ -985,12 +986,14 @@ public class FeedManager {
});
}
new Thread() {
@Override
public void run() {
autodownloadUndownloadedItems(context);
}
}.start();
if (performAutoDownload) {
new Thread() {
@Override
public void run() {
autodownloadUndownloadedItems(context);
}
}.start();
}
eventDist.sendQueueUpdateBroadcast();
}

View File

@ -730,7 +730,7 @@ public class PlaybackService extends Service {
isInQueue = media instanceof FeedMedia
&& manager.isInQueue(((FeedMedia) media).getItem());
if (isInQueue) {
manager.removeQueueItem(PlaybackService.this, item);
manager.removeQueueItem(PlaybackService.this, item, true);
}
manager.addItemToPlaybackHistory(PlaybackService.this, item);
manager.setFeedMedia(PlaybackService.this, (FeedMedia) media);

View File

@ -140,7 +140,7 @@ public class FeedItemMenuHandler {
manager.addQueueItem(context, selectedItem);
break;
case R.id.remove_from_queue_item:
manager.removeQueueItem(context, selectedItem);
manager.removeQueueItem(context, selectedItem, true);
break;
case R.id.stream_item:
manager.playMedia(context, selectedItem.getMedia(), true, true,