mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-26 08:44:13 +01:00
Feeds can now be removed in the background
This commit is contained in:
parent
9533323167
commit
22918164c7
62
src/de/podfetcher/asynctask/FeedRemover.java
Normal file
62
src/de/podfetcher/asynctask/FeedRemover.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
package de.podfetcher.asynctask;
|
||||||
|
|
||||||
|
import de.podfetcher.feed.Feed;
|
||||||
|
import de.podfetcher.feed.FeedManager;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnCancelListener;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
/** Removes a feed in the background. */
|
||||||
|
public class FeedRemover extends AsyncTask<Feed, Void, Void> {
|
||||||
|
Context context;
|
||||||
|
ProgressDialog dialog;
|
||||||
|
|
||||||
|
public FeedRemover(Context context) {
|
||||||
|
super();
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Feed... params) {
|
||||||
|
FeedManager manager = FeedManager.getInstance();
|
||||||
|
for (Feed feed : params) {
|
||||||
|
manager.deleteFeed(context, feed);
|
||||||
|
if (isCancelled()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCancelled() {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void result) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
dialog = new ProgressDialog(context);
|
||||||
|
dialog.setMessage("Removing Feed");
|
||||||
|
dialog.setOnCancelListener(new OnCancelListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
cancel(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ import de.podfetcher.R;
|
|||||||
import de.podfetcher.feed.*;
|
import de.podfetcher.feed.*;
|
||||||
import de.podfetcher.activity.*;
|
import de.podfetcher.activity.*;
|
||||||
import de.podfetcher.adapter.FeedlistAdapter;
|
import de.podfetcher.adapter.FeedlistAdapter;
|
||||||
|
import de.podfetcher.asynctask.FeedRemover;
|
||||||
import de.podfetcher.storage.DownloadRequester;
|
import de.podfetcher.storage.DownloadRequester;
|
||||||
import de.podfetcher.service.DownloadService;
|
import de.podfetcher.service.DownloadService;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -148,8 +149,14 @@ public class FeedlistFragment extends SherlockListFragment {
|
|||||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.remove_item:
|
case R.id.remove_item:
|
||||||
manager.deleteFeed(getSherlockActivity(), selectedFeed);
|
FeedRemover remover = new FeedRemover(getSherlockActivity()){
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void result) {
|
||||||
|
super.onPostExecute(result);
|
||||||
fla.notifyDataSetChanged();
|
fla.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
remover.execute(selectedFeed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mode.finish();
|
mode.finish();
|
||||||
|
Loading…
Reference in New Issue
Block a user