Skip to content

Commit

Permalink
[ProgressIndicator] Added demos for wave effects with wave speed.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 621630725
  • Loading branch information
pekingme authored and paulfthomas committed Apr 3, 2024
1 parent 2a80e16 commit 0849c14
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ public void initDemoControls(@NonNull View view) {
circularIndicator.setWavelength(newWaveLength);
}
});
Slider speedSlider = view.findViewById(R.id.speed_slider);
speedSlider.addOnChangeListener(
(slider, value, fromUser) -> {
int newSpeed = (int) (value * pixelsInDp);
if (linearIndicator.getSpeed() != newSpeed) {
linearIndicator.setSpeed(newSpeed);
}
if (circularIndicator.getSpeed() != newSpeed) {
circularIndicator.setSpeed(newSpeed);
}
});

Slider circularSizeSlider = view.findViewById(R.id.circularSizeSlider);
circularSizeSlider.addOnChangeListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@
android:valueTo="100"
android:stepSize="1"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cat_progress_indicator_wave_speed"/>
<com.google.android.material.slider.Slider
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/speed_slider"
android:valueFrom="-50"
android:valueTo="50"
android:value="0"
android:stepSize="1"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
Standalone Drawable Progress Indicator Demo
</string>
<string name="cat_progress_indicator_wave_demo_title"
description="Title of demo for applying wave effects on progress indicators [CHAR LIMIT=NONE]">
description="Title of demo for applying wave effects on progress indicators [CHAR LIMIT=NONE]">
Wavy Progress Indicator Demo
</string>
<string name="cat_progress_indicator_description"
Expand Down Expand Up @@ -103,6 +103,10 @@
description="Text label above a slider for changing indicators' wavelength [CHAR LIMIT=NONE]">
Wave length (0 - 100) dp
</string>
<string name="cat_progress_indicator_wave_speed"
description="Text label above a slider for changing indicators' speed [CHAR LIMIT=NONE]">
Wave speed (-50 - 50) dp/s
</string>

<!-- Descriptions of various examples of progress indicators -->

Expand Down

0 comments on commit 0849c14

Please sign in to comment.