Search in sources :

Example 1 with ToolbarIconTintManager

use of de.danoeh.antennapod.view.ToolbarIconTintManager in project AntennaPod by AntennaPod.

the class FeedInfoFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.feedinfo, null);
    toolbar = root.findViewById(R.id.toolbar);
    toolbar.setTitle("");
    toolbar.inflateMenu(R.menu.feedinfo);
    toolbar.setNavigationOnClickListener(v -> getParentFragmentManager().popBackStack());
    toolbar.setOnMenuItemClickListener(this);
    refreshToolbarState();
    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.visit_website_item).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_web));
            toolbar.getMenu().findItem(R.id.share_parent).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_share));
        }
    };
    iconTintManager.updateTint();
    appBar.addOnOffsetChangedListener(iconTintManager);
    imgvCover = root.findViewById(R.id.imgvCover);
    txtvTitle = root.findViewById(R.id.txtvTitle);
    txtvAuthorHeader = root.findViewById(R.id.txtvAuthor);
    imgvBackground = root.findViewById(R.id.imgvBackground);
    header = root.findViewById(R.id.headerContainer);
    infoContainer = root.findViewById(R.id.infoContainer);
    root.findViewById(R.id.butShowInfo).setVisibility(View.INVISIBLE);
    root.findViewById(R.id.butShowSettings).setVisibility(View.INVISIBLE);
    // https://github.com/bumptech/glide/issues/529
    imgvBackground.setColorFilter(new LightingColorFilter(0xff828282, 0x000000));
    txtvDescription = root.findViewById(R.id.txtvDescription);
    txtvUrl = root.findViewById(R.id.txtvUrl);
    lblSupport = root.findViewById(R.id.lblSupport);
    txtvFundingUrl = root.findViewById(R.id.txtvFundingUrl);
    txtvUrl.setOnClickListener(copyUrlToClipboard);
    long feedId = getArguments().getLong(EXTRA_FEED_ID);
    getParentFragmentManager().beginTransaction().replace(R.id.statisticsFragmentContainer, FeedStatisticsFragment.newInstance(feedId, false), "feed_statistics_fragment").commitAllowingStateLoss();
    root.findViewById(R.id.btnvOpenStatistics).setOnClickListener(view -> {
        StatisticsFragment fragment = new StatisticsFragment();
        ((MainActivity) getActivity()).loadChildFragment(fragment, TransitionEffect.SLIDE);
    });
    return root;
}
Also used : Context(android.content.Context) StatisticsFragment(de.danoeh.antennapod.fragment.preferences.StatisticsFragment) LightingColorFilter(android.graphics.LightingColorFilter) CollapsingToolbarLayout(com.google.android.material.appbar.CollapsingToolbarLayout) AppBarLayout(com.google.android.material.appbar.AppBarLayout) MainActivity(de.danoeh.antennapod.activity.MainActivity) ToolbarIconTintManager(de.danoeh.antennapod.view.ToolbarIconTintManager) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable)

Example 2 with ToolbarIconTintManager

use of de.danoeh.antennapod.view.ToolbarIconTintManager 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)

Aggregations

Context (android.content.Context)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 Nullable (androidx.annotation.Nullable)2 AppBarLayout (com.google.android.material.appbar.AppBarLayout)2 CollapsingToolbarLayout (com.google.android.material.appbar.CollapsingToolbarLayout)2 MainActivity (de.danoeh.antennapod.activity.MainActivity)2 ToolbarIconTintManager (de.danoeh.antennapod.view.ToolbarIconTintManager)2 LightingColorFilter (android.graphics.LightingColorFilter)1 Handler (android.os.Handler)1 AdapterView (android.widget.AdapterView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)1 IconTextView (com.joanzapata.iconify.widget.IconTextView)1 SpeedDialView (com.leinardi.android.speeddial.SpeedDialView)1 MoreContentListFooterUtil (de.danoeh.antennapod.core.util.gui.MoreContentListFooterUtil)1 EpisodeMultiSelectActionHandler (de.danoeh.antennapod.fragment.actions.EpisodeMultiSelectActionHandler)1 StatisticsFragment (de.danoeh.antennapod.fragment.preferences.StatisticsFragment)1 FeedItemMenuHandler (de.danoeh.antennapod.menuhandler.FeedItemMenuHandler)1