use of com.github.rubensousa.previewseekbar.animator.PreviewMorphAnimator in project PreviewSeekBar by rubensousa.
the class MainActivity method setupOptions.
private void setupOptions() {
// Enable or disable the previews
SwitchCompat previewSwitch = findViewById(R.id.previewEnabledSwitch);
previewSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
previewTimeBar.setPreviewEnabled(isChecked);
previewSeekBar.setPreviewEnabled(isChecked);
});
// Enable or disable auto-hide mode of previews
SwitchCompat previewAutoHideSwitch = findViewById(R.id.previewAutoHideSwitch);
previewAutoHideSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
exoPlayerManager.setResumeVideoOnPreviewStop(isChecked);
previewTimeBar.setAutoHidePreview(isChecked);
previewSeekBar.setAutoHidePreview(isChecked);
});
// Change the animations
RadioGroup animationRadioGroup = findViewById(R.id.previewAnimationRadioGroup);
animationRadioGroup.setOnCheckedChangeListener((group, checkedId) -> {
if (checkedId == R.id.noAnimationRadioButton) {
previewTimeBar.setPreviewAnimationEnabled(false);
previewSeekBar.setPreviewAnimationEnabled(false);
} else {
previewTimeBar.setPreviewAnimationEnabled(true);
previewSeekBar.setPreviewAnimationEnabled(true);
if (checkedId == R.id.fadeAnimationRadioButton) {
previewTimeBar.setPreviewAnimator(new PreviewFadeAnimator());
previewSeekBar.setPreviewAnimator(new PreviewFadeAnimator());
} else if (Build.VERSION.SDK_INT >= 21) {
previewTimeBar.setPreviewAnimator(new PreviewMorphAnimator());
previewSeekBar.setPreviewAnimator(new PreviewMorphAnimator());
}
}
});
// Toggle previews
Button toggleButton = findViewById(R.id.previewToggleButton);
toggleButton.setOnClickListener(v -> {
if (previewTimeBar.isShowingPreview()) {
previewTimeBar.hidePreview();
} else {
previewTimeBar.showPreview();
exoPlayerManager.loadPreview(previewTimeBar.getProgress(), previewTimeBar.getMax());
}
if (previewSeekBar.isShowingPreview()) {
previewSeekBar.hidePreview();
} else {
previewSeekBar.showPreview();
}
});
// Change colors
Button changeColorsButton = findViewById(R.id.previewToggleColors);
changeColorsButton.setOnClickListener(v -> {
final int seekBarColor = previewSeekBar.getScrubberColor();
final int timeBarColor = previewTimeBar.getScrubberColor();
previewSeekBar.setPreviewThumbTint(timeBarColor);
previewSeekBar.setProgressTint(timeBarColor);
previewTimeBar.setPreviewThumbTint(seekBarColor);
previewTimeBar.setPlayedColor(seekBarColor);
});
}
Aggregations