Search in sources :

Example 1 with SpeedDialView

use of com.leinardi.android.speeddial.SpeedDialView in project AntennaPod by AntennaPod.

the class CompletedDownloadsFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.simple_list_fragment, container, false);
    Toolbar toolbar = root.findViewById(R.id.toolbar);
    toolbar.setVisibility(View.GONE);
    recyclerView = root.findViewById(R.id.recyclerView);
    recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
    adapter = new CompletedDownloadsListAdapter((MainActivity) getActivity());
    adapter.setOnSelectModeListener(this);
    recyclerView.setAdapter(adapter);
    progressBar = root.findViewById(R.id.progLoading);
    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.download_batch);
    speedDialView.removeActionItemById(R.id.mark_read_batch);
    speedDialView.removeActionItemById(R.id.mark_unread_batch);
    speedDialView.removeActionItemById(R.id.remove_from_queue_batch);
    speedDialView.setOnChangeListener(new SpeedDialView.OnChangeListener() {

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

        @Override
        public void onToggleChanged(boolean open) {
            if (open && adapter.getSelectedCount() == 0) {
                ((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.no_items_selected, Snackbar.LENGTH_SHORT);
                speedDialView.close();
            }
        }
    });
    speedDialView.setOnActionSelectedListener(actionItem -> {
        new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), adapter.getSelectedItems()).handleAction(actionItem.getId());
        adapter.endSelectMode();
        return true;
    });
    addEmptyView();
    EventBus.getDefault().register(this);
    return root;
}
Also used : EpisodeMultiSelectActionHandler(de.danoeh.antennapod.fragment.actions.EpisodeMultiSelectActionHandler) MainActivity(de.danoeh.antennapod.activity.MainActivity) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) View(android.view.View) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView) Toolbar(androidx.appcompat.widget.Toolbar)

Example 2 with SpeedDialView

use of com.leinardi.android.speeddial.SpeedDialView in project Conversations by siacs.

the class StartConversationActivity method inflateFab.

private void inflateFab(final SpeedDialView speedDialView, @MenuRes final int menuRes) {
    speedDialView.clearActionItems();
    final PopupMenu popupMenu = new PopupMenu(this, new View(this));
    popupMenu.inflate(menuRes);
    final Menu menu = popupMenu.getMenu();
    for (int i = 0; i < menu.size(); i++) {
        final MenuItem menuItem = menu.getItem(i);
        final SpeedDialActionItem actionItem = new SpeedDialActionItem.Builder(menuItem.getItemId(), menuItem.getIcon()).setLabel(menuItem.getTitle() != null ? menuItem.getTitle().toString() : null).setFabImageTintColor(ContextCompat.getColor(this, R.color.white)).create();
        speedDialView.addActionItem(actionItem);
    }
}
Also used : SpeedDialActionItem(com.leinardi.android.speeddial.SpeedDialActionItem) MenuItem(android.view.MenuItem) ContextMenu(android.view.ContextMenu) Menu(android.view.Menu) PopupMenu(androidx.appcompat.widget.PopupMenu) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AutoCompleteTextView(android.widget.AutoCompleteTextView) SuppressLint(android.annotation.SuppressLint) PopupMenu(androidx.appcompat.widget.PopupMenu)

Example 3 with SpeedDialView

use of com.leinardi.android.speeddial.SpeedDialView in project AntennaPod by AntennaPod.

the class FeedItemlistFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.feed_item_list_fragment, container, false);
    toolbar = root.findViewById(R.id.toolbar);
    toolbar.inflateMenu(R.menu.feedlist);
    toolbar.setOnMenuItemClickListener(this);
    displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
    if (savedInstanceState != null) {
        displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);
    }
    ((MainActivity) getActivity()).setupToolbarToggle(toolbar, displayUpArrow);
    refreshToolbarState();
    recyclerView = root.findViewById(R.id.recyclerView);
    recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
    progressBar = root.findViewById(R.id.progLoading);
    progressBar.setVisibility(View.VISIBLE);
    txtvTitle = root.findViewById(R.id.txtvTitle);
    txtvAuthor = root.findViewById(R.id.txtvAuthor);
    imgvBackground = root.findViewById(R.id.imgvBackground);
    imgvCover = root.findViewById(R.id.imgvCover);
    butShowInfo = root.findViewById(R.id.butShowInfo);
    butShowSettings = root.findViewById(R.id.butShowSettings);
    txtvInformation = root.findViewById(R.id.txtvInformation);
    txtvFailure = root.findViewById(R.id.txtvFailure);
    txtvUpdatesDisabled = root.findViewById(R.id.txtvUpdatesDisabled);
    header = root.findViewById(R.id.headerContainer);
    AppBarLayout appBar = root.findViewById(R.id.appBar);
    CollapsingToolbarLayout collapsingToolbar = root.findViewById(R.id.collapsing_toolbar);
    ToolbarIconTintManager iconTintManager = new ToolbarIconTintManager(getContext(), toolbar, collapsingToolbar) {

        @Override
        protected void doTint(Context themedContext) {
            toolbar.getMenu().findItem(R.id.sort_items).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_sort));
            toolbar.getMenu().findItem(R.id.filter_items).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_filter));
            toolbar.getMenu().findItem(R.id.refresh_item).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_refresh));
            toolbar.getMenu().findItem(R.id.action_search).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_search));
        }
    };
    iconTintManager.updateTint();
    appBar.addOnOffsetChangedListener(iconTintManager);
    nextPageLoader = new MoreContentListFooterUtil(root.findViewById(R.id.more_content_list_footer));
    nextPageLoader.setClickListener(() -> {
        if (feed != null) {
            DBTasks.loadNextPageOfFeed(getActivity(), feed, false);
        }
    });
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(@NonNull RecyclerView view, int deltaX, int deltaY) {
            super.onScrolled(view, deltaX, deltaY);
            boolean hasMorePages = feed != null && feed.isPaged() && feed.getNextPageLink() != null;
            nextPageLoader.getRoot().setVisibility((recyclerView.isScrolledToBottom() && hasMorePages) ? View.VISIBLE : View.GONE);
        }
    });
    EventBus.getDefault().register(this);
    SwipeRefreshLayout swipeRefreshLayout = root.findViewById(R.id.swipeRefresh);
    swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance));
    swipeRefreshLayout.setOnRefreshListener(() -> {
        DBTasks.forceRefreshFeed(requireContext(), feed, true);
        new Handler(Looper.getMainLooper()).postDelayed(() -> swipeRefreshLayout.setRefreshing(false), getResources().getInteger(R.integer.swipe_to_refresh_duration_in_ms));
    });
    loadItems();
    // Init action UI (via a FAB Speed Dial)
    speedDialView = root.findViewById(R.id.fabSD);
    speedDialView.setOverlayLayout(root.findViewById(R.id.fabSDOverlay));
    speedDialView.inflate(R.menu.episodes_apply_action_speeddial);
    speedDialView.setOnChangeListener(new SpeedDialView.OnChangeListener() {

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

        @Override
        public void onToggleChanged(boolean open) {
            if (open && adapter.getSelectedCount() == 0) {
                ((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.no_items_selected, Snackbar.LENGTH_SHORT);
                speedDialView.close();
            }
        }
    });
    speedDialView.setOnActionSelectedListener(actionItem -> {
        new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), adapter.getSelectedItems()).handleAction(actionItem.getId());
        adapter.endSelectMode();
        return true;
    });
    return root;
}
Also used : Context(android.content.Context) FeedItemMenuHandler(de.danoeh.antennapod.menuhandler.FeedItemMenuHandler) Handler(android.os.Handler) FeedMenuHandler(de.danoeh.antennapod.menuhandler.FeedMenuHandler) 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) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) IconTextView(com.joanzapata.iconify.widget.IconTextView) MoreContentListFooterUtil(de.danoeh.antennapod.core.util.gui.MoreContentListFooterUtil) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) CollapsingToolbarLayout(com.google.android.material.appbar.CollapsingToolbarLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) AppBarLayout(com.google.android.material.appbar.AppBarLayout) ToolbarIconTintManager(de.danoeh.antennapod.view.ToolbarIconTintManager) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView) Nullable(androidx.annotation.Nullable)

Example 4 with SpeedDialView

use of com.leinardi.android.speeddial.SpeedDialView 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)

Example 5 with SpeedDialView

use of com.leinardi.android.speeddial.SpeedDialView 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

View (android.view.View)5 SpeedDialView (com.leinardi.android.speeddial.SpeedDialView)5 TextView (android.widget.TextView)4 MainActivity (de.danoeh.antennapod.activity.MainActivity)4 Handler (android.os.Handler)3 RecyclerView (androidx.recyclerview.widget.RecyclerView)3 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)3 EpisodeMultiSelectActionHandler (de.danoeh.antennapod.fragment.actions.EpisodeMultiSelectActionHandler)3 EpisodeItemListRecyclerView (de.danoeh.antennapod.view.EpisodeItemListRecyclerView)3 SuppressLint (android.annotation.SuppressLint)2 AdapterView (android.widget.AdapterView)2 FeedItemMenuHandler (de.danoeh.antennapod.menuhandler.FeedItemMenuHandler)2 EmptyViewHandler (de.danoeh.antennapod.view.EmptyViewHandler)2 Context (android.content.Context)1 ContextMenu (android.view.ContextMenu)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1