Search in sources :

Example 1 with FavoriteActionBarView

use of com.simplecity.amp_library.ui.views.FavoriteActionBarView in project Shuttle by timusus.

the class PlayerFragment method favoriteChanged.

@Override
public void favoriteChanged(boolean isFavorite) {
    FavoriteActionBarView favoriteActionBarView = (FavoriteActionBarView) toolbar.getMenu().findItem(R.id.favorite).getActionView();
    favoriteActionBarView.setIsFavorite(isFavorite);
}
Also used : FavoriteActionBarView(com.simplecity.amp_library.ui.views.FavoriteActionBarView)

Example 2 with FavoriteActionBarView

use of com.simplecity.amp_library.ui.views.FavoriteActionBarView in project Shuttle by timusus.

the class PlayerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_player, container, false);
    isLandscape = ShuttleUtils.isLandscape();
    unbinder = ButterKnife.bind(this, rootView);
    toolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed());
    toolbar.inflateMenu(R.menu.menu_now_playing);
    setupCastMenu(toolbar.getMenu());
    MenuItem favoriteMenuItem = toolbar.getMenu().findItem(R.id.favorite);
    FavoriteActionBarView menuActionView = (FavoriteActionBarView) favoriteMenuItem.getActionView();
    menuActionView.setOnClickListener(v -> onMenuItemClick(favoriteMenuItem));
    toolbar.setOnMenuItemClickListener(this);
    if (playPauseView != null) {
        playPauseView.setOnClickListener(v -> {
            playPauseView.toggle();
            playPauseView.postDelayed(() -> presenter.togglePlayback(), 200);
        });
    }
    if (repeatButton != null) {
        repeatButton.setOnClickListener(v -> presenter.toggleRepeat());
    }
    if (shuffleButton != null) {
        shuffleButton.setOnClickListener(v -> presenter.toggleShuffle());
    }
    if (nextButton != null) {
        nextButton.setOnClickListener(v -> presenter.skip());
        nextButton.setRepeatListener((v, duration, repeatCount) -> presenter.scanForward(repeatCount, duration));
    }
    if (prevButton != null) {
        prevButton.setOnClickListener(v -> presenter.prev(true));
        prevButton.setRepeatListener((v, duration, repeatCount) -> presenter.scanBackward(repeatCount, duration));
    }
    if (seekBar != null) {
        seekBar.setMax(1000);
    }
    if (savedInstanceState == null) {
        getChildFragmentManager().beginTransaction().add(R.id.main_container, QueuePagerFragment.newInstance(), "QueuePagerFragment").commit();
    }
    return rootView;
}
Also used : MenuItem(android.view.MenuItem) FavoriteActionBarView(com.simplecity.amp_library.ui.views.FavoriteActionBarView) ImageView(android.widget.ImageView) FavoriteActionBarView(com.simplecity.amp_library.ui.views.FavoriteActionBarView) BindView(butterknife.BindView) View(android.view.View) PlayPauseView(com.simplecity.amp_library.ui.views.PlayPauseView) TextView(android.widget.TextView) SnowfallView(com.simplecity.amp_library.ui.views.SnowfallView) PlayerView(com.simplecity.amp_library.ui.views.PlayerView)

Example 3 with FavoriteActionBarView

use of com.simplecity.amp_library.ui.views.FavoriteActionBarView in project Shuttle by timusus.

the class PlayerFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    isLandscape = ShuttleUtils.isLandscape(getContext());
    unbinder = ButterKnife.bind(this, view);
    toolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed());
    toolbar.inflateMenu(R.menu.menu_now_playing);
    if (CastManager.isCastAvailable(getContext(), settingsManager)) {
        MenuItem menuItem = CastButtonFactory.setUpMediaRouteButton(getContext(), toolbar.getMenu(), R.id.media_route_menu_item);
        menuItem.setVisible(true);
    }
    MenuItem favoriteMenuItem = toolbar.getMenu().findItem(R.id.favorite);
    FavoriteActionBarView menuActionView = (FavoriteActionBarView) favoriteMenuItem.getActionView();
    menuActionView.setOnClickListener(v -> onMenuItemClick(favoriteMenuItem));
    toolbar.setOnMenuItemClickListener(this);
    if (playPauseView != null) {
        playPauseView.setOnClickListener(v -> playPauseView.toggle(() -> {
            presenter.togglePlayback();
            return Unit.INSTANCE;
        }));
    }
    if (repeatButton != null) {
        repeatButton.setOnClickListener(v -> presenter.toggleRepeat());
        repeatButton.setTag(":aesthetic_ignore");
    }
    if (shuffleButton != null) {
        shuffleButton.setOnClickListener(v -> presenter.toggleShuffle());
        shuffleButton.setTag(":aesthetic_ignore");
    }
    if (nextButton != null) {
        nextButton.setOnClickListener(v -> presenter.skip());
        nextButton.setRepeatListener((v, duration, repeatCount) -> presenter.scanForward(repeatCount, duration));
    }
    if (prevButton != null) {
        prevButton.setOnClickListener(v -> presenter.prev(false));
        prevButton.setRepeatListener((v, duration, repeatCount) -> presenter.scanBackward(repeatCount, duration));
    }
    if (seekBar != null) {
        seekBar.setMax(1000);
    }
    if (savedInstanceState == null) {
        getChildFragmentManager().beginTransaction().add(R.id.main_container, QueuePagerFragment.newInstance(), "QueuePagerFragment").commit();
    }
    getAestheticColorSetDisposable().take(1).subscribe(this::invalidateColors, error -> {
    // Nothing to do
    });
    presenter.bindView(this);
}
Also used : MenuItem(android.view.MenuItem) FavoriteActionBarView(com.simplecity.amp_library.ui.views.FavoriteActionBarView)

Example 4 with FavoriteActionBarView

use of com.simplecity.amp_library.ui.views.FavoriteActionBarView in project Shuttle by timusus.

the class PlayerFragment method favoriteChanged.

@Override
public void favoriteChanged(boolean isFavorite) {
    FavoriteActionBarView favoriteActionBarView = (FavoriteActionBarView) toolbar.getMenu().findItem(R.id.favorite).getActionView();
    favoriteActionBarView.setIsFavorite(isFavorite);
}
Also used : FavoriteActionBarView(com.simplecity.amp_library.ui.views.FavoriteActionBarView)

Aggregations

FavoriteActionBarView (com.simplecity.amp_library.ui.views.FavoriteActionBarView)4 MenuItem (android.view.MenuItem)2 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 PlayPauseView (com.simplecity.amp_library.ui.views.PlayPauseView)1 PlayerView (com.simplecity.amp_library.ui.views.PlayerView)1 SnowfallView (com.simplecity.amp_library.ui.views.SnowfallView)1