Search in sources :

Example 1 with VariableSpeedDialog

use of de.danoeh.antennapod.dialog.VariableSpeedDialog in project AntennaPod by AntennaPod.

the class AudioPlayerFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View root = inflater.inflate(R.layout.audioplayer_fragment, container, false);
    // Avoid clicks going through player to fragments below
    root.setOnTouchListener((v, event) -> true);
    toolbar = root.findViewById(R.id.toolbar);
    toolbar.setTitle("");
    toolbar.setNavigationOnClickListener(v -> ((MainActivity) getActivity()).getBottomSheet().setState(BottomSheetBehavior.STATE_COLLAPSED));
    toolbar.setOnMenuItemClickListener(this);
    ExternalPlayerFragment externalPlayerFragment = new ExternalPlayerFragment();
    getChildFragmentManager().beginTransaction().replace(R.id.playerFragment, externalPlayerFragment, ExternalPlayerFragment.TAG).commit();
    butPlaybackSpeed = root.findViewById(R.id.butPlaybackSpeed);
    txtvPlaybackSpeed = root.findViewById(R.id.txtvPlaybackSpeed);
    sbPosition = root.findViewById(R.id.sbPosition);
    txtvPosition = root.findViewById(R.id.txtvPosition);
    txtvLength = root.findViewById(R.id.txtvLength);
    butRev = root.findViewById(R.id.butRev);
    txtvRev = root.findViewById(R.id.txtvRev);
    butPlay = root.findViewById(R.id.butPlay);
    butFF = root.findViewById(R.id.butFF);
    txtvFF = root.findViewById(R.id.txtvFF);
    butSkip = root.findViewById(R.id.butSkip);
    progressIndicator = root.findViewById(R.id.progLoading);
    cardViewSeek = root.findViewById(R.id.cardViewSeek);
    txtvSeek = root.findViewById(R.id.txtvSeek);
    setupLengthTextView();
    setupControlButtons();
    butPlaybackSpeed.setOnClickListener(v -> new VariableSpeedDialog().show(getChildFragmentManager(), null));
    sbPosition.setOnSeekBarChangeListener(this);
    pager = root.findViewById(R.id.pager);
    pager.setAdapter(new AudioPlayerPagerAdapter(this));
    // Required for getChildAt(int) in ViewPagerBottomSheetBehavior to return the correct page
    pager.setOffscreenPageLimit((int) NUM_CONTENT_FRAGMENTS);
    pager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {

        @Override
        public void onPageSelected(int position) {
            pager.post(() -> {
                if (getActivity() != null) {
                    // By the time this is posted, the activity might be closed again.
                    ((MainActivity) getActivity()).getBottomSheet().updateScrollingChild();
                }
            });
        }
    });
    return root;
}
Also used : ViewPager2(androidx.viewpager2.widget.ViewPager2) MainActivity(de.danoeh.antennapod.activity.MainActivity) VariableSpeedDialog(de.danoeh.antennapod.dialog.VariableSpeedDialog) View(android.view.View) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) PlaybackSpeedIndicatorView(de.danoeh.antennapod.ui.common.PlaybackSpeedIndicatorView)

Example 2 with VariableSpeedDialog

use of de.danoeh.antennapod.dialog.VariableSpeedDialog in project AntennaPod by AntennaPod.

the class PlaybackPreferencesFragment method setupPlaybackScreen.

private void setupPlaybackScreen() {
    final Activity activity = getActivity();
    findPreference(PREF_PLAYBACK_SPEED_LAUNCHER).setOnPreferenceClickListener(preference -> {
        new VariableSpeedDialog().show(getChildFragmentManager(), null);
        return true;
    });
    findPreference(PREF_PLAYBACK_REWIND_DELTA_LAUNCHER).setOnPreferenceClickListener(preference -> {
        SkipPreferenceDialog.showSkipPreference(activity, SkipPreferenceDialog.SkipDirection.SKIP_REWIND, null);
        return true;
    });
    findPreference(PREF_PLAYBACK_FAST_FORWARD_DELTA_LAUNCHER).setOnPreferenceClickListener(preference -> {
        SkipPreferenceDialog.showSkipPreference(activity, SkipPreferenceDialog.SkipDirection.SKIP_FORWARD, null);
        return true;
    });
    if (!PictureInPictureUtil.supportsPictureInPicture(activity)) {
        ListPreference behaviour = findPreference(UserPreferences.PREF_VIDEO_BEHAVIOR);
        behaviour.setEntries(R.array.video_background_behavior_options_without_pip);
        behaviour.setEntryValues(R.array.video_background_behavior_values_without_pip);
    }
    findPreference(PREF_PLAYBACK_PREFER_STREAMING).setOnPreferenceChangeListener((preference, newValue) -> {
        // Update all visible lists to reflect new streaming action button
        EventBus.getDefault().post(new UnreadItemsUpdateEvent());
        UsageStatistics.askAgainLater(UsageStatistics.ACTION_STREAM);
        return true;
    });
    buildEnqueueLocationPreference();
}
Also used : UnreadItemsUpdateEvent(de.danoeh.antennapod.event.UnreadItemsUpdateEvent) PreferenceActivity(de.danoeh.antennapod.activity.PreferenceActivity) Activity(android.app.Activity) ListPreference(androidx.preference.ListPreference) VariableSpeedDialog(de.danoeh.antennapod.dialog.VariableSpeedDialog)

Aggregations

VariableSpeedDialog (de.danoeh.antennapod.dialog.VariableSpeedDialog)2 Activity (android.app.Activity)1 View (android.view.View)1 TextView (android.widget.TextView)1 CardView (androidx.cardview.widget.CardView)1 ListPreference (androidx.preference.ListPreference)1 ViewPager2 (androidx.viewpager2.widget.ViewPager2)1 MainActivity (de.danoeh.antennapod.activity.MainActivity)1 PreferenceActivity (de.danoeh.antennapod.activity.PreferenceActivity)1 UnreadItemsUpdateEvent (de.danoeh.antennapod.event.UnreadItemsUpdateEvent)1 PlaybackSpeedIndicatorView (de.danoeh.antennapod.ui.common.PlaybackSpeedIndicatorView)1