Search in sources :

Example 1 with ThemesAdapter

use of com.github.anrimian.musicplayer.ui.settings.themes.view.ThemesAdapter in project music-player by Anrimian.

the class ThemeSettingsFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    themeController = Components.getAppComponent().themeController();
    AdvancedToolbar toolbar = requireActivity().findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.settings);
    toolbar.setSubtitle(R.string.theme);
    toolbar.setTitleClickListener(null);
    slidrInterface = SlidrPanel.simpleSwipeBack(viewBinding.nsvContainer, this, toolbar::onStackFragmentSlided);
    viewBinding.rvThemes.setLayoutManager(new GridLayoutManager(requireContext(), 2, RecyclerView.HORIZONTAL, false));
    viewBinding.rvThemes.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            onAlbumsScrolled(viewBinding.rvThemes.computeHorizontalScrollOffset() == 0);
        }
    });
    adapter = new ThemesAdapter(AppTheme.values(), themeController.getCurrentTheme(), this::onThemeClicked);
    viewBinding.rvThemes.setAdapter(adapter);
    setChecked(viewBinding.cbAutoNightMode, themeController.isAutoDarkThemeEnabled());
    viewBinding.cbAutoNightMode.setOnCheckedChangeListener((v, isChecked) -> themeController.setAutoDarkModeEnabled(requireActivity(), isChecked));
}
Also used : ThemesAdapter(com.github.anrimian.musicplayer.ui.settings.themes.view.ThemesAdapter) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) AdvancedToolbar(com.github.anrimian.musicplayer.ui.common.toolbar.AdvancedToolbar)

Aggregations

GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 AdvancedToolbar (com.github.anrimian.musicplayer.ui.common.toolbar.AdvancedToolbar)1 ThemesAdapter (com.github.anrimian.musicplayer.ui.settings.themes.view.ThemesAdapter)1