Demo: Read long values from trim slider.

Before, slider values were read as `floor()`'ed `longValue()`s, so that trimming to
intervals less than one second would be interpreted as a request for a zero-
duration trim.

Also, rename `radiusRange` references here to `trimRange`, since this is not a
radius range.

PiperOrigin-RevId: 480401556
(cherry picked from commit 6c59f9ece40f6450405d29acd559492145158409)
This commit is contained in:
huangdarwin 2022-10-11 17:57:01 +00:00 committed by microkatz
parent 5d8daba5c5
commit abefef9b59

View File

@ -435,17 +435,17 @@ public final class ConfigurationActivity extends AppCompatActivity {
return;
}
View dialogView = getLayoutInflater().inflate(R.layout.trim_options, /* root= */ null);
RangeSlider radiusRangeSlider =
RangeSlider trimRangeSlider =
checkNotNull(dialogView.findViewById(R.id.trim_bounds_range_slider));
radiusRangeSlider.setValues(0f, 60f); // seconds
trimRangeSlider.setValues(0f, 60f); // seconds
new AlertDialog.Builder(/* context= */ this)
.setView(dialogView)
.setPositiveButton(
android.R.string.ok,
(DialogInterface dialogInterface, int i) -> {
List<Float> radiusRange = radiusRangeSlider.getValues();
trimStartMs = 1000 * radiusRange.get(0).longValue();
trimEndMs = 1000 * radiusRange.get(1).longValue();
List<Float> trimRange = trimRangeSlider.getValues();
trimStartMs = Math.round(1000 * trimRange.get(0));
trimEndMs = Math.round(1000 * trimRange.get(1));
})
.create()
.show();