Search in sources :

Example 1 with FeedRemover

use of de.danoeh.antennapod.core.asynctask.FeedRemover in project AntennaPod by AntennaPod.

the class MediaplayerInfoActivity method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    final int position = mPosition;
    // reset
    mPosition = -1;
    if (position < 0) {
        return false;
    }
    Feed feed = navDrawerData.feeds.get(position - navAdapter.getSubscriptionOffset());
    switch(item.getItemId()) {
        case R.id.mark_all_seen_item:
            DBWriter.markFeedSeen(feed.getId());
            return true;
        case R.id.mark_all_read_item:
            DBWriter.markFeedRead(feed.getId());
            return true;
        case R.id.rename_item:
            new RenameFeedDialog(this, feed).show();
            return true;
        case R.id.remove_item:
            final FeedRemover remover = new FeedRemover(this, feed) {

                @Override
                protected void onPostExecute(Void result) {
                    super.onPostExecute(result);
                }
            };
            ConfirmationDialog conDialog = new ConfirmationDialog(this, R.string.remove_feed_label, R.string.feed_delete_confirmation_msg) {

                @Override
                public void onConfirmButtonPressed(DialogInterface dialog) {
                    dialog.dismiss();
                    if (controller != null) {
                        Playable playable = controller.getMedia();
                        if (playable != null && playable instanceof FeedMedia) {
                            FeedMedia media = (FeedMedia) playable;
                            if (media.getItem().getFeed().getId() == feed.getId()) {
                                Log.d(TAG, "Currently playing episode is about to be deleted, skipping");
                                remover.skipOnCompletion = true;
                                if (controller.getStatus() == PlayerStatus.PLAYING) {
                                    sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
                                }
                            }
                        }
                    }
                    remover.executeAsync();
                }
            };
            conDialog.createNewDialog().show();
            return true;
        default:
            return super.onContextItemSelected(item);
    }
}
Also used : FeedRemover(de.danoeh.antennapod.core.asynctask.FeedRemover) DialogInterface(android.content.DialogInterface) Playable(de.danoeh.antennapod.core.util.playback.Playable) FeedMedia(de.danoeh.antennapod.core.feed.FeedMedia) RenameFeedDialog(de.danoeh.antennapod.dialog.RenameFeedDialog) Intent(android.content.Intent) Feed(de.danoeh.antennapod.core.feed.Feed) ConfirmationDialog(de.danoeh.antennapod.core.dialog.ConfirmationDialog)

Example 2 with FeedRemover

use of de.danoeh.antennapod.core.asynctask.FeedRemover in project AntennaPod by AntennaPod.

the class MainActivity method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    final int position = mPosition;
    // reset
    mPosition = -1;
    if (position < 0) {
        return false;
    }
    Feed feed = navDrawerData.feeds.get(position - navAdapter.getSubscriptionOffset());
    switch(item.getItemId()) {
        case R.id.mark_all_seen_item:
            DBWriter.markFeedSeen(feed.getId());
            return true;
        case R.id.mark_all_read_item:
            DBWriter.markFeedRead(feed.getId());
            return true;
        case R.id.rename_item:
            new RenameFeedDialog(this, feed).show();
            return true;
        case R.id.remove_item:
            final FeedRemover remover = new FeedRemover(this, feed) {

                @Override
                protected void onPostExecute(Void result) {
                    super.onPostExecute(result);
                    if (getSelectedNavListIndex() == position) {
                        loadFragment(EpisodesFragment.TAG, null);
                    }
                }
            };
            ConfirmationDialog conDialog = new ConfirmationDialog(this, R.string.remove_feed_label, R.string.feed_delete_confirmation_msg) {

                @Override
                public void onConfirmButtonPressed(DialogInterface dialog) {
                    dialog.dismiss();
                    long mediaId = PlaybackPreferences.getCurrentlyPlayingFeedMediaId();
                    if (mediaId > 0 && FeedItemUtil.indexOfItemWithMediaId(feed.getItems(), mediaId) >= 0) {
                        Log.d(TAG, "Currently playing episode is about to be deleted, skipping");
                        remover.skipOnCompletion = true;
                        int playerStatus = PlaybackPreferences.getCurrentPlayerStatus();
                        if (playerStatus == PlaybackPreferences.PLAYER_STATUS_PLAYING) {
                            sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
                        }
                    }
                    remover.executeAsync();
                }
            };
            conDialog.createNewDialog().show();
            return true;
        default:
            return super.onContextItemSelected(item);
    }
}
Also used : FeedRemover(de.danoeh.antennapod.core.asynctask.FeedRemover) DialogInterface(android.content.DialogInterface) RenameFeedDialog(de.danoeh.antennapod.dialog.RenameFeedDialog) Intent(android.content.Intent) Feed(de.danoeh.antennapod.core.feed.Feed) ConfirmationDialog(de.danoeh.antennapod.core.dialog.ConfirmationDialog)

Example 3 with FeedRemover

use of de.danoeh.antennapod.core.asynctask.FeedRemover in project AntennaPod by AntennaPod.

the class ItemlistFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (!super.onOptionsItemSelected(item)) {
        try {
            if (!FeedMenuHandler.onOptionsItemClicked(getActivity(), item, feed)) {
                switch(item.getItemId()) {
                    case R.id.episode_actions:
                        EpisodesApplyActionFragment fragment = EpisodesApplyActionFragment.newInstance(feed.getItems());
                        ((MainActivity) getActivity()).loadChildFragment(fragment);
                        return true;
                    case R.id.rename_item:
                        new RenameFeedDialog(getActivity(), feed).show();
                        return true;
                    case R.id.remove_item:
                        final FeedRemover remover = new FeedRemover(getActivity(), feed) {

                            @Override
                            protected void onPostExecute(Void result) {
                                super.onPostExecute(result);
                                ((MainActivity) getActivity()).loadFragment(EpisodesFragment.TAG, null);
                            }
                        };
                        ConfirmationDialog conDialog = new ConfirmationDialog(getActivity(), R.string.remove_feed_label, R.string.feed_delete_confirmation_msg) {

                            @Override
                            public void onConfirmButtonPressed(DialogInterface dialog) {
                                dialog.dismiss();
                                remover.executeAsync();
                            }
                        };
                        conDialog.createNewDialog().show();
                        return true;
                    default:
                        return false;
                }
            } else {
                return true;
            }
        } catch (DownloadRequestException e) {
            e.printStackTrace();
            DownloadRequestErrorDialogCreator.newRequestErrorDialog(getActivity(), e.getMessage());
            return true;
        }
    } else {
        return true;
    }
}
Also used : FeedRemover(de.danoeh.antennapod.core.asynctask.FeedRemover) DialogInterface(android.content.DialogInterface) RenameFeedDialog(de.danoeh.antennapod.dialog.RenameFeedDialog) EpisodesApplyActionFragment(de.danoeh.antennapod.dialog.EpisodesApplyActionFragment) MainActivity(de.danoeh.antennapod.activity.MainActivity) DownloadRequestException(de.danoeh.antennapod.core.storage.DownloadRequestException) ConfirmationDialog(de.danoeh.antennapod.core.dialog.ConfirmationDialog)

Aggregations

DialogInterface (android.content.DialogInterface)3 FeedRemover (de.danoeh.antennapod.core.asynctask.FeedRemover)3 ConfirmationDialog (de.danoeh.antennapod.core.dialog.ConfirmationDialog)3 RenameFeedDialog (de.danoeh.antennapod.dialog.RenameFeedDialog)3 Intent (android.content.Intent)2 Feed (de.danoeh.antennapod.core.feed.Feed)2 MainActivity (de.danoeh.antennapod.activity.MainActivity)1 FeedMedia (de.danoeh.antennapod.core.feed.FeedMedia)1 DownloadRequestException (de.danoeh.antennapod.core.storage.DownloadRequestException)1 Playable (de.danoeh.antennapod.core.util.playback.Playable)1 EpisodesApplyActionFragment (de.danoeh.antennapod.dialog.EpisodesApplyActionFragment)1