Search in sources :

Example 1 with MainActivity

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

the class QueueFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (!super.onOptionsItemSelected(item)) {
        switch(item.getItemId()) {
            case R.id.queue_lock:
                boolean newLockState = !UserPreferences.isQueueLocked();
                UserPreferences.setQueueLocked(newLockState);
                getActivity().supportInvalidateOptionsMenu();
                recyclerAdapter.setLocked(newLockState);
                if (newLockState) {
                    Snackbar.make(getActivity().findViewById(R.id.content), R.string.queue_locked, Snackbar.LENGTH_SHORT).show();
                } else {
                    Snackbar.make(getActivity().findViewById(R.id.content), R.string.queue_unlocked, Snackbar.LENGTH_SHORT).show();
                }
                return true;
            case R.id.refresh_item:
                List<Feed> feeds = ((MainActivity) getActivity()).getFeeds();
                if (feeds != null) {
                    DBTasks.refreshAllFeeds(getActivity(), feeds);
                }
                return true;
            case R.id.clear_queue:
                // make sure the user really wants to clear the queue
                ConfirmationDialog conDialog = new ConfirmationDialog(getActivity(), R.string.clear_queue_label, R.string.clear_queue_confirmation_msg) {

                    @Override
                    public void onConfirmButtonPressed(DialogInterface dialog) {
                        dialog.dismiss();
                        DBWriter.clearQueue();
                    }
                };
                conDialog.createNewDialog().show();
                return true;
            case R.id.queue_sort_episode_title_asc:
                QueueSorter.sort(getActivity(), QueueSorter.Rule.EPISODE_TITLE_ASC, true);
                return true;
            case R.id.queue_sort_episode_title_desc:
                QueueSorter.sort(getActivity(), QueueSorter.Rule.EPISODE_TITLE_DESC, true);
                return true;
            case R.id.queue_sort_date_asc:
                QueueSorter.sort(getActivity(), QueueSorter.Rule.DATE_ASC, true);
                return true;
            case R.id.queue_sort_date_desc:
                QueueSorter.sort(getActivity(), QueueSorter.Rule.DATE_DESC, true);
                return true;
            case R.id.queue_sort_duration_asc:
                QueueSorter.sort(getActivity(), QueueSorter.Rule.DURATION_ASC, true);
                return true;
            case R.id.queue_sort_duration_desc:
                QueueSorter.sort(getActivity(), QueueSorter.Rule.DURATION_DESC, true);
                return true;
            case R.id.queue_sort_feed_title_asc:
                QueueSorter.sort(getActivity(), QueueSorter.Rule.FEED_TITLE_ASC, true);
                return true;
            case R.id.queue_sort_feed_title_desc:
                QueueSorter.sort(getActivity(), QueueSorter.Rule.FEED_TITLE_DESC, true);
                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 2 with MainActivity

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

the class AllEpisodesFragment method onFragmentLoaded.

private void onFragmentLoaded() {
    if (listAdapter == null) {
        MainActivity mainActivity = (MainActivity) getActivity();
        listAdapter = new AllEpisodesRecycleAdapter(mainActivity, itemAccess, new DefaultActionButtonCallback(mainActivity), showOnlyNewEpisodes());
        listAdapter.setHasStableIds(true);
        recyclerView.setAdapter(listAdapter);
    }
    listAdapter.notifyDataSetChanged();
    restoreScrollPosition();
    getActivity().supportInvalidateOptionsMenu();
    updateShowOnlyEpisodesListViewState();
}
Also used : DefaultActionButtonCallback(de.danoeh.antennapod.adapter.DefaultActionButtonCallback) AllEpisodesRecycleAdapter(de.danoeh.antennapod.adapter.AllEpisodesRecycleAdapter) MainActivity(de.danoeh.antennapod.activity.MainActivity)

Example 3 with MainActivity

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

the class CompletedDownloadsFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.episode_actions:
            EpisodesApplyActionFragment fragment = EpisodesApplyActionFragment.newInstance(items, EpisodesApplyActionFragment.ACTION_REMOVE);
            ((MainActivity) getActivity()).loadChildFragment(fragment);
            return true;
        default:
            return false;
    }
}
Also used : EpisodesApplyActionFragment(de.danoeh.antennapod.dialog.EpisodesApplyActionFragment) MainActivity(de.danoeh.antennapod.activity.MainActivity)

Example 4 with MainActivity

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

the class TagListFragment 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 SearchView.OnQueryTextListener() {

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

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

Example 5 with MainActivity

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

the class SubscriptionFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    subscriptionAdapter = new SubscriptionsAdapter((MainActivity) getActivity(), itemAccess);
    subscriptionGridLayout.setAdapter(subscriptionAdapter);
    loadSubscriptions();
    subscriptionGridLayout.setOnItemClickListener(subscriptionAdapter);
    if (getActivity() instanceof MainActivity) {
        ((MainActivity) getActivity()).getSupportActionBar().setTitle(R.string.subscriptions_label);
    }
    EventDistributor.getInstance().register(contentUpdate);
}
Also used : SubscriptionsAdapter(de.danoeh.antennapod.adapter.SubscriptionsAdapter) MainActivity(de.danoeh.antennapod.activity.MainActivity)

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