Search in sources :

Example 26 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 27 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)

Example 28 with MainActivity

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

the class ItemlistFragment method onListItemClick.

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    if (adapter == null) {
        return;
    }
    position -= l.getHeaderViewsCount();
    MainActivity activity = (MainActivity) getActivity();
    long[] ids = FeedItemUtil.getIds(feed.getItems());
    activity.loadChildFragment(ItemFragment.newInstance(ids, position));
    activity.getSupportActionBar().setTitle(feed.getTitle());
}
Also used : MainActivity(de.danoeh.antennapod.activity.MainActivity)

Example 29 with MainActivity

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

the class PodcastListFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.gpodder_podcasts, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
    MenuItemUtils.adjustTextColor(getActivity(), sv);
    sv.setQueryHint(getString(R.string.gpodnet_search_hint));
    sv.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            sv.clearFocus();
            MainActivity activity = (MainActivity) getActivity();
            if (activity != null) {
                activity.loadChildFragment(SearchListFragment.newInstance(s));
            }
            return true;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem) MainActivity(de.danoeh.antennapod.activity.MainActivity)

Example 30 with MainActivity

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

the class DownloadsFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View root = inflater.inflate(R.layout.pager_fragment, container, false);
    Toolbar toolbar = root.findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.downloads_label);
    toolbar.inflateMenu(R.menu.downloads);
    displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
    if (savedInstanceState != null) {
        displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);
    }
    ((MainActivity) getActivity()).setupToolbarToggle(toolbar, displayUpArrow);
    viewPager = root.findViewById(R.id.viewpager);
    viewPager.setAdapter(new DownloadsPagerAdapter(this));
    viewPager.setOffscreenPageLimit(2);
    super.setupPagedToolbar(toolbar, viewPager);
    // Give the TabLayout the ViewPager
    tabLayout = root.findViewById(R.id.sliding_tabs);
    new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
        switch(position) {
            case POS_COMPLETED:
                tab.setText(R.string.downloads_completed_label);
                break;
            case POS_LOG:
                tab.setText(R.string.downloads_log_label);
                break;
            default:
                break;
        }
    }).attach();
    // restore our last position
    SharedPreferences prefs = getActivity().getSharedPreferences(TAG, Context.MODE_PRIVATE);
    int lastPosition = prefs.getInt(PREF_LAST_TAB_POSITION, 0);
    viewPager.setCurrentItem(lastPosition, false);
    return root;
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) TabLayout(com.google.android.material.tabs.TabLayout) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull) R(de.danoeh.antennapod.R) ViewPager2(androidx.viewpager2.widget.ViewPager2) ViewGroup(android.view.ViewGroup) FragmentStateAdapter(androidx.viewpager2.adapter.FragmentStateAdapter) MainActivity(de.danoeh.antennapod.activity.MainActivity) Nullable(androidx.annotation.Nullable) SharedPreferences(android.content.SharedPreferences) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar) TabLayoutMediator(com.google.android.material.tabs.TabLayoutMediator) SharedPreferences(android.content.SharedPreferences) TabLayoutMediator(com.google.android.material.tabs.TabLayoutMediator) MainActivity(de.danoeh.antennapod.activity.MainActivity) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

MainActivity (de.danoeh.antennapod.activity.MainActivity)43 View (android.view.View)15 TextView (android.widget.TextView)11 Nullable (androidx.annotation.Nullable)6 Context (android.content.Context)5 ImageView (android.widget.ImageView)5 Fragment (androidx.fragment.app.Fragment)5 EpisodeItemListRecyclerView (de.danoeh.antennapod.view.EpisodeItemListRecyclerView)5 DialogInterface (android.content.DialogInterface)4 Bundle (android.os.Bundle)4 MenuItem (android.view.MenuItem)4 NonNull (androidx.annotation.NonNull)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 ConfirmationDialog (de.danoeh.antennapod.core.dialog.ConfirmationDialog)4 EmptyViewHandler (de.danoeh.antennapod.view.EmptyViewHandler)4 Activity (android.app.Activity)3 Handler (android.os.Handler)3 ViewGroup (android.view.ViewGroup)3 Toolbar (androidx.appcompat.widget.Toolbar)3 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)3