Search in sources :

Example 11 with DownloadRequestException

use of de.danoeh.antennapod.core.storage.DownloadRequestException in project AntennaPod by AntennaPod.

the class QueueFragment method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    Log.d(TAG, "onContextItemSelected() called with: " + "item = [" + item + "]");
    if (!isVisible()) {
        return false;
    }
    FeedItem selectedItem = recyclerAdapter.getSelectedItem();
    if (selectedItem == null) {
        Log.i(TAG, "Selected item was null, ignoring selection");
        return super.onContextItemSelected(item);
    }
    switch(item.getItemId()) {
        case R.id.move_to_top_item:
            int position = FeedItemUtil.indexOfItemWithId(queue, selectedItem.getId());
            queue.add(0, queue.remove(position));
            recyclerAdapter.notifyItemMoved(position, 0);
            DBWriter.moveQueueItemToTop(selectedItem.getId(), true);
            return true;
        case R.id.move_to_bottom_item:
            position = FeedItemUtil.indexOfItemWithId(queue, selectedItem.getId());
            queue.add(queue.size() - 1, queue.remove(position));
            recyclerAdapter.notifyItemMoved(position, queue.size() - 1);
            DBWriter.moveQueueItemToBottom(selectedItem.getId(), true);
            return true;
        default:
            try {
                return FeedItemMenuHandler.onMenuItemClicked(getActivity(), item.getItemId(), selectedItem);
            } catch (DownloadRequestException e) {
                e.printStackTrace();
                Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
                return true;
            }
    }
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) DownloadRequestException(de.danoeh.antennapod.core.storage.DownloadRequestException)

Example 12 with DownloadRequestException

use of de.danoeh.antennapod.core.storage.DownloadRequestException in project AntennaPod by AntennaPod.

the class SPAReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    if (!TextUtils.equals(intent.getAction(), ACTION_SP_APPS_QUERY_FEEDS_REPSONSE)) {
        return;
    }
    Log.d(TAG, "Received SP_APPS_QUERY_RESPONSE");
    if (!intent.hasExtra(ACTION_SP_APPS_QUERY_FEEDS_REPSONSE_FEEDS_EXTRA)) {
        Log.e(TAG, "Received invalid SP_APPS_QUERY_RESPONSE: Contains no extra");
        return;
    }
    String[] feedUrls = intent.getStringArrayExtra(ACTION_SP_APPS_QUERY_FEEDS_REPSONSE_FEEDS_EXTRA);
    if (feedUrls == null) {
        Log.e(TAG, "Received invalid SP_APPS_QUERY_REPSONSE: extra was null");
        return;
    }
    Log.d(TAG, "Received feeds list: " + Arrays.toString(feedUrls));
    ClientConfig.initialize(context);
    for (String url : feedUrls) {
        Feed f = new Feed(url, null);
        try {
            DownloadRequester.getInstance().downloadFeed(context, f);
        } catch (DownloadRequestException e) {
            Log.e(TAG, "Error while trying to add feed " + url);
            e.printStackTrace();
        }
    }
    Toast.makeText(context, R.string.sp_apps_importing_feeds_msg, Toast.LENGTH_LONG).show();
}
Also used : DownloadRequestException(de.danoeh.antennapod.core.storage.DownloadRequestException) Feed(de.danoeh.antennapod.core.feed.Feed)

Example 13 with DownloadRequestException

use of de.danoeh.antennapod.core.storage.DownloadRequestException 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

DownloadRequestException (de.danoeh.antennapod.core.storage.DownloadRequestException)13 FeedItem (de.danoeh.antennapod.core.feed.FeedItem)4 AdapterView (android.widget.AdapterView)3 Feed (de.danoeh.antennapod.core.feed.Feed)3 Intent (android.content.Intent)2 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 GpodnetService (de.danoeh.antennapod.core.gpoddernet.GpodnetService)2 GpodnetServiceException (de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException)2 ArrayList (java.util.ArrayList)2 SuppressLint (android.annotation.SuppressLint)1 DialogInterface (android.content.DialogInterface)1 SearchView (android.support.v7.widget.SearchView)1 ArrayAdapter (android.widget.ArrayAdapter)1 Spinner (android.widget.Spinner)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 IconTextView (com.joanzapata.iconify.widget.IconTextView)1