Search in sources :

Example 11 with MainActivity

use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.

the class CoverTarget method onLoadFailed.

@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
    String fallbackUri = fallback.get();
    TextView txtvPlaceholder = placeholder.get();
    ImageView imgvCover = cover.get();
    if (fallbackUri != null && txtvPlaceholder != null && imgvCover != null) {
        MainActivity activity = mainActivity.get();
        Glide.with(activity).load(fallbackUri).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).fitCenter().dontAnimate().into(new CoverTarget(null, txtvPlaceholder, imgvCover, activity));
    }
}
Also used : TextView(android.widget.TextView) ImageView(android.widget.ImageView) MainActivity(de.danoeh.antennapod.activity.MainActivity)

Example 12 with MainActivity

use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.

the class SearchFragment method onListItemClick.

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    SearchResult result = (SearchResult) l.getAdapter().getItem(position);
    FeedComponent comp = result.getComponent();
    if (comp.getClass() == Feed.class) {
        ((MainActivity) getActivity()).loadFeedFragmentById(comp.getId(), null);
    } else {
        if (comp.getClass() == FeedItem.class) {
            FeedItem item = (FeedItem) comp;
            ((MainActivity) getActivity()).loadChildFragment(ItemFragment.newInstance(item.getId()));
        }
    }
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) SearchResult(de.danoeh.antennapod.core.feed.SearchResult) FeedComponent(de.danoeh.antennapod.core.feed.FeedComponent) MainActivity(de.danoeh.antennapod.activity.MainActivity)

Example 13 with MainActivity

use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.

the class AllEpisodesFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (!super.onOptionsItemSelected(item)) {
        switch(item.getItemId()) {
            case R.id.refresh_item:
                List<Feed> feeds = ((MainActivity) getActivity()).getFeeds();
                if (feeds != null) {
                    DBTasks.refreshAllFeeds(getActivity(), feeds);
                }
                return true;
            case R.id.mark_all_read_item:
                ConfirmationDialog markAllReadConfirmationDialog = new ConfirmationDialog(getActivity(), R.string.mark_all_read_label, R.string.mark_all_read_confirmation_msg) {

                    @Override
                    public void onConfirmButtonPressed(DialogInterface dialog) {
                        dialog.dismiss();
                        DBWriter.markAllItemsRead();
                        Toast.makeText(getActivity(), R.string.mark_all_read_msg, Toast.LENGTH_SHORT).show();
                    }
                };
                markAllReadConfirmationDialog.createNewDialog().show();
                return true;
            case R.id.mark_all_seen_item:
                ConfirmationDialog markAllSeenConfirmationDialog = new ConfirmationDialog(getActivity(), R.string.mark_all_seen_label, R.string.mark_all_seen_confirmation_msg) {

                    @Override
                    public void onConfirmButtonPressed(DialogInterface dialog) {
                        dialog.dismiss();
                        DBWriter.markNewItemsSeen();
                        Toast.makeText(getActivity(), R.string.mark_all_seen_msg, Toast.LENGTH_SHORT).show();
                    }
                };
                markAllSeenConfirmationDialog.createNewDialog().show();
                return true;
            default:
                return false;
        }
    } else {
        return true;
    }
}
Also used : DialogInterface(android.content.DialogInterface) MainActivity(de.danoeh.antennapod.activity.MainActivity) Feed(de.danoeh.antennapod.core.feed.Feed) ConfirmationDialog(de.danoeh.antennapod.core.dialog.ConfirmationDialog)

Example 14 with MainActivity

use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.

the class ItemFragment method openPodcast.

private void openPodcast() {
    Fragment fragment = ItemlistFragment.newInstance(item.getFeedId());
    ((MainActivity) getActivity()).loadChildFragment(fragment);
}
Also used : MainActivity(de.danoeh.antennapod.activity.MainActivity) Fragment(android.support.v4.app.Fragment)

Example 15 with MainActivity

use of de.danoeh.antennapod.activity.MainActivity 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

MainActivity (de.danoeh.antennapod.activity.MainActivity)17 DialogInterface (android.content.DialogInterface)3 View (android.view.View)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 DefaultActionButtonCallback (de.danoeh.antennapod.adapter.DefaultActionButtonCallback)3 ConfirmationDialog (de.danoeh.antennapod.core.dialog.ConfirmationDialog)3 Intent (android.content.Intent)2 SearchView (android.support.v7.widget.SearchView)2 MenuItem (android.view.MenuItem)2 Feed (de.danoeh.antennapod.core.feed.Feed)2 EpisodesApplyActionFragment (de.danoeh.antennapod.dialog.EpisodesApplyActionFragment)2 Activity (android.app.Activity)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Fragment (android.support.v4.app.Fragment)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 Button (android.widget.Button)1