Search in sources :

Example 1 with FeedItemFilter

use of de.danoeh.antennapod.model.feed.FeedItemFilter in project AntennaPod by AntennaPod.

the class FeedItemlistFragment method refreshHeaderView.

private void refreshHeaderView() {
    setupHeaderView();
    if (recyclerView == null || feed == null) {
        Log.e(TAG, "Unable to refresh header view");
        return;
    }
    loadFeedImage();
    if (feed.hasLastUpdateFailed()) {
        txtvFailure.setVisibility(View.VISIBLE);
    } else {
        txtvFailure.setVisibility(View.GONE);
    }
    if (!feed.getPreferences().getKeepUpdated()) {
        txtvUpdatesDisabled.setText("{md-pause-circle-outline} " + this.getString(R.string.updates_disabled_label));
        Iconify.addIcons(txtvUpdatesDisabled);
        txtvUpdatesDisabled.setVisibility(View.VISIBLE);
    } else {
        txtvUpdatesDisabled.setVisibility(View.GONE);
    }
    txtvTitle.setText(feed.getTitle());
    txtvAuthor.setText(feed.getAuthor());
    if (feed.getItemFilter() != null) {
        FeedItemFilter filter = feed.getItemFilter();
        if (filter.getValues().length > 0) {
            txtvInformation.setText("{md-info-outline} " + this.getString(R.string.filtered_label));
            Iconify.addIcons(txtvInformation);
            txtvInformation.setOnClickListener((l) -> {
                FilterDialog filterDialog = new FilterDialog(requireContext(), feed.getItemFilter()) {

                    @Override
                    protected void updateFilter(Set<String> filterValues) {
                        feed.setItemFilter(filterValues.toArray(new String[0]));
                        DBWriter.setFeedItemsFilter(feed.getId(), filterValues);
                    }
                };
                filterDialog.openDialog();
            });
            txtvInformation.setVisibility(View.VISIBLE);
        } else {
            txtvInformation.setVisibility(View.GONE);
        }
    } else {
        txtvInformation.setVisibility(View.GONE);
    }
}
Also used : Set(java.util.Set) FeedItemFilter(de.danoeh.antennapod.model.feed.FeedItemFilter) FilterDialog(de.danoeh.antennapod.dialog.FilterDialog)

Example 2 with FeedItemFilter

use of de.danoeh.antennapod.model.feed.FeedItemFilter in project AntennaPod by AntennaPod.

the class AllEpisodesFragment method showFilterDialog.

private void showFilterDialog() {
    FilterDialog filterDialog = new FilterDialog(getContext(), feedItemFilter) {

        @Override
        protected void updateFilter(Set<String> filterValues) {
            feedItemFilter = new FeedItemFilter(filterValues.toArray(new String[0]));
            SharedPreferences prefs = getActivity().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
            prefs.edit().putString(PREF_FILTER, StringUtils.join(filterValues, ",")).apply();
            loadItems();
        }
    };
    filterDialog.openDialog();
}
Also used : Set(java.util.Set) SharedPreferences(android.content.SharedPreferences) FeedItemFilter(de.danoeh.antennapod.model.feed.FeedItemFilter) FilterDialog(de.danoeh.antennapod.dialog.FilterDialog)

Example 3 with FeedItemFilter

use of de.danoeh.antennapod.model.feed.FeedItemFilter in project AntennaPod by AntennaPod.

the class AllEpisodesFragment method shouldUpdatedItemRemainInList.

@Override
protected boolean shouldUpdatedItemRemainInList(FeedItem item) {
    SharedPreferences prefs = getActivity().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
    FeedItemFilter feedItemFilter = new FeedItemFilter(prefs.getString(PREF_FILTER, ""));
    if (feedItemFilter.isShowDownloaded() && (!item.hasMedia() || !item.getMedia().isDownloaded())) {
        return false;
    }
    return true;
}
Also used : SharedPreferences(android.content.SharedPreferences) FeedItemFilter(de.danoeh.antennapod.model.feed.FeedItemFilter)

Example 4 with FeedItemFilter

use of de.danoeh.antennapod.model.feed.FeedItemFilter in project AntennaPod by AntennaPod.

the class AllEpisodesFragment method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SharedPreferences prefs = getActivity().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
    feedItemFilter = new FeedItemFilter(prefs.getString(PREF_FILTER, ""));
}
Also used : SharedPreferences(android.content.SharedPreferences) FeedItemFilter(de.danoeh.antennapod.model.feed.FeedItemFilter)

Example 5 with FeedItemFilter

use of de.danoeh.antennapod.model.feed.FeedItemFilter in project AntennaPod by AntennaPod.

the class QueueFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View root = inflater.inflate(R.layout.queue_fragment, container, false);
    toolbar = root.findViewById(R.id.toolbar);
    toolbar.setOnMenuItemClickListener(this);
    displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
    if (savedInstanceState != null) {
        displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);
    }
    ((MainActivity) getActivity()).setupToolbarToggle(toolbar, displayUpArrow);
    toolbar.inflateMenu(R.menu.queue);
    refreshToolbarState();
    infoBar = root.findViewById(R.id.info_bar);
    recyclerView = root.findViewById(R.id.recyclerView);
    RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
    if (animator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
    }
    recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
    registerForContextMenu(recyclerView);
    SwipeRefreshLayout swipeRefreshLayout = root.findViewById(R.id.swipeRefresh);
    swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance));
    swipeRefreshLayout.setOnRefreshListener(() -> {
        AutoUpdateManager.runImmediate(requireContext());
        new Handler(Looper.getMainLooper()).postDelayed(() -> swipeRefreshLayout.setRefreshing(false), getResources().getInteger(R.integer.swipe_to_refresh_duration_in_ms));
    });
    swipeActions = new QueueSwipeActions();
    swipeActions.setFilter(new FeedItemFilter(FeedItemFilter.QUEUED));
    swipeActions.attachTo(recyclerView);
    emptyView = new EmptyViewHandler(getContext());
    emptyView.attachToRecyclerView(recyclerView);
    emptyView.setIcon(R.drawable.ic_playlist);
    emptyView.setTitle(R.string.no_items_header_label);
    emptyView.setMessage(R.string.no_items_label);
    progLoading = root.findViewById(R.id.progLoading);
    progLoading.setVisibility(View.VISIBLE);
    speedDialView = root.findViewById(R.id.fabSD);
    speedDialView.setOverlayLayout(root.findViewById(R.id.fabSDOverlay));
    speedDialView.inflate(R.menu.episodes_apply_action_speeddial);
    speedDialView.removeActionItemById(R.id.mark_read_batch);
    speedDialView.removeActionItemById(R.id.mark_unread_batch);
    speedDialView.removeActionItemById(R.id.add_to_queue_batch);
    speedDialView.setOnChangeListener(new SpeedDialView.OnChangeListener() {

        @Override
        public boolean onMainActionSelected() {
            return false;
        }

        @Override
        public void onToggleChanged(boolean open) {
            if (open && recyclerAdapter.getSelectedCount() == 0) {
                ((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.no_items_selected, Snackbar.LENGTH_SHORT);
                speedDialView.close();
            }
        }
    });
    speedDialView.setOnActionSelectedListener(actionItem -> {
        new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), recyclerAdapter.getSelectedItems()).handleAction(actionItem.getId());
        recyclerAdapter.endSelectMode();
        return true;
    });
    return root;
}
Also used : SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) EmptyViewHandler(de.danoeh.antennapod.view.EmptyViewHandler) FeedItemFilter(de.danoeh.antennapod.model.feed.FeedItemFilter) FeedItemMenuHandler(de.danoeh.antennapod.menuhandler.FeedItemMenuHandler) Handler(android.os.Handler) EmptyViewHandler(de.danoeh.antennapod.view.EmptyViewHandler) EpisodeMultiSelectActionHandler(de.danoeh.antennapod.fragment.actions.EpisodeMultiSelectActionHandler) EpisodeMultiSelectActionHandler(de.danoeh.antennapod.fragment.actions.EpisodeMultiSelectActionHandler) MainActivity(de.danoeh.antennapod.activity.MainActivity) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView)

Aggregations

FeedItemFilter (de.danoeh.antennapod.model.feed.FeedItemFilter)5 SharedPreferences (android.content.SharedPreferences)3 FilterDialog (de.danoeh.antennapod.dialog.FilterDialog)2 Set (java.util.Set)2 Handler (android.os.Handler)1 View (android.view.View)1 TextView (android.widget.TextView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 SimpleItemAnimator (androidx.recyclerview.widget.SimpleItemAnimator)1 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)1 SpeedDialView (com.leinardi.android.speeddial.SpeedDialView)1 MainActivity (de.danoeh.antennapod.activity.MainActivity)1 EpisodeMultiSelectActionHandler (de.danoeh.antennapod.fragment.actions.EpisodeMultiSelectActionHandler)1 FeedItemMenuHandler (de.danoeh.antennapod.menuhandler.FeedItemMenuHandler)1 EmptyViewHandler (de.danoeh.antennapod.view.EmptyViewHandler)1 EpisodeItemListRecyclerView (de.danoeh.antennapod.view.EpisodeItemListRecyclerView)1