Search in sources :

Example 1 with FeedMultiSelectActionHandler

use of de.danoeh.antennapod.fragment.actions.FeedMultiSelectActionHandler in project AntennaPod by AntennaPod.

the class SubscriptionFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_subscriptions, 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.subscriptions);
    for (int i = 0; i < COLUMN_CHECKBOX_IDS.length; i++) {
        // Do this in Java to localize numbers
        toolbar.getMenu().findItem(COLUMN_CHECKBOX_IDS[i]).setTitle(String.format(Locale.getDefault(), "%d", i + MIN_NUM_COLUMNS));
    }
    refreshToolbarState();
    if (getArguments() != null) {
        displayedFolder = getArguments().getString(ARGUMENT_FOLDER, null);
        if (displayedFolder != null) {
            toolbar.setTitle(displayedFolder);
        }
    }
    subscriptionRecycler = root.findViewById(R.id.subscriptions_grid);
    GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), prefs.getInt(PREF_NUM_COLUMNS, getDefaultNumOfColumns()), RecyclerView.VERTICAL, false);
    subscriptionRecycler.setLayoutManager(gridLayoutManager);
    subscriptionRecycler.addItemDecoration(new SubscriptionsRecyclerAdapter.GridDividerItemDecorator());
    gridLayoutManager.setSpanCount(prefs.getInt(PREF_NUM_COLUMNS, getDefaultNumOfColumns()));
    registerForContextMenu(subscriptionRecycler);
    subscriptionAddButton = root.findViewById(R.id.subscriptions_add);
    progressBar = root.findViewById(R.id.progLoading);
    feedsFilteredMsg = root.findViewById(R.id.feeds_filtered_message);
    feedsFilteredMsg.setOnClickListener((l) -> SubscriptionsFilterDialog.showDialog(requireContext()));
    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));
    });
    speedDialView = root.findViewById(R.id.fabSD);
    speedDialView.setOverlayLayout(root.findViewById(R.id.fabSDOverlay));
    speedDialView.inflate(R.menu.nav_feed_action_speeddial);
    speedDialView.setOnChangeListener(new SpeedDialView.OnChangeListener() {

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

        @Override
        public void onToggleChanged(boolean isOpen) {
        }
    });
    speedDialView.setOnActionSelectedListener(actionItem -> {
        new FeedMultiSelectActionHandler((MainActivity) getActivity(), subscriptionAdapter.getSelectedItems()).handleAction(actionItem.getId());
        return true;
    });
    return root;
}
Also used : Handler(android.os.Handler) EmptyViewHandler(de.danoeh.antennapod.view.EmptyViewHandler) FeedMultiSelectActionHandler(de.danoeh.antennapod.fragment.actions.FeedMultiSelectActionHandler) 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) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) SuppressLint(android.annotation.SuppressLint) SubscriptionsRecyclerAdapter(de.danoeh.antennapod.adapter.SubscriptionsRecyclerAdapter) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView) FeedMultiSelectActionHandler(de.danoeh.antennapod.fragment.actions.FeedMultiSelectActionHandler)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 Handler (android.os.Handler)1 View (android.view.View)1 TextView (android.widget.TextView)1 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)1 SpeedDialView (com.leinardi.android.speeddial.SpeedDialView)1 MainActivity (de.danoeh.antennapod.activity.MainActivity)1 SubscriptionsRecyclerAdapter (de.danoeh.antennapod.adapter.SubscriptionsRecyclerAdapter)1 FeedMultiSelectActionHandler (de.danoeh.antennapod.fragment.actions.FeedMultiSelectActionHandler)1 EmptyViewHandler (de.danoeh.antennapod.view.EmptyViewHandler)1