From c4cf6b28e17d80e48a124a41b62208f62d869617 Mon Sep 17 00:00:00 2001 From: pekingme <8545955+pekingme@users.noreply.github.com> Date: Wed, 1 May 2024 17:43:01 +0000 Subject: [PATCH] [ProgressIndicator] Added demos for wave effects with new indeterminate motion. PiperOrigin-RevId: 629767094 --- .../ProgressIndicatorWaveDemoFragment.java | 21 ++++++++- .../cat_progress_indicator_wave_controls.xml | 44 +++++++++++++++---- .../progressindicator/res/values/strings.xml | 12 +++++ 3 files changed, 67 insertions(+), 10 deletions(-) diff --git a/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorWaveDemoFragment.java b/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorWaveDemoFragment.java index 6618f95370a..419f81f36dd 100644 --- a/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorWaveDemoFragment.java +++ b/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorWaveDemoFragment.java @@ -17,9 +17,13 @@ import io.material.catalog.R; +import static com.google.android.material.progressindicator.CircularProgressIndicator.INDETERMINATE_ANIMATION_TYPE_ADVANCE; +import static com.google.android.material.progressindicator.CircularProgressIndicator.INDETERMINATE_ANIMATION_TYPE_RETREAT; + import android.view.View; import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; +import com.google.android.material.button.MaterialButtonToggleGroup; import com.google.android.material.materialswitch.MaterialSwitch; import com.google.android.material.progressindicator.CircularProgressIndicator; import com.google.android.material.progressindicator.LinearProgressIndicator; @@ -44,6 +48,8 @@ public void initDemoContents(@NonNull View view) { public void initDemoControls(@NonNull View view) { Slider progressSlider = view.findViewById(R.id.progress_slider); MaterialSwitch determinateSwitch = view.findViewById(R.id.determinate_mode_switch); + MaterialButtonToggleGroup circularAnimationMode = + view.findViewById(R.id.circular_animation_mode); progressSlider.addOnChangeListener( (slider, value, fromUser) -> { @@ -66,6 +72,7 @@ public void initDemoControls(@NonNull View view) { linearIndicator.setIndeterminate(true); circularIndicator.setIndeterminate(true); } + circularAnimationMode.setEnabled(isChecked); }); float pixelsInDp = view.getResources().getDisplayMetrics().density; @@ -104,7 +111,7 @@ public void initDemoControls(@NonNull View view) { } }); - Slider circularSizeSlider = view.findViewById(R.id.circularSizeSlider); + Slider circularSizeSlider = view.findViewById(R.id.circular_size_slider); circularSizeSlider.addOnChangeListener( (slider, value, fromUser) -> { int newCornerRadius = (int) (value * pixelsInDp); @@ -112,6 +119,18 @@ public void initDemoControls(@NonNull View view) { circularIndicator.setIndicatorSize(newCornerRadius); } }); + + circularAnimationMode.addOnButtonCheckedListener( + (group, checkedId, isChecked) -> { + if (!isChecked) { + return; + } + if (checkedId == R.id.circular_advance_animation) { + circularIndicator.setIndeterminateAnimationType(INDETERMINATE_ANIMATION_TYPE_ADVANCE); + } else { + circularIndicator.setIndeterminateAnimationType(INDETERMINATE_ANIMATION_TYPE_RETREAT); + } + }); } @Override diff --git a/catalog/java/io/material/catalog/progressindicator/res/layout/cat_progress_indicator_wave_controls.xml b/catalog/java/io/material/catalog/progressindicator/res/layout/cat_progress_indicator_wave_controls.xml index 57b8ee51b21..56513f9dc25 100644 --- a/catalog/java/io/material/catalog/progressindicator/res/layout/cat_progress_indicator_wave_controls.xml +++ b/catalog/java/io/material/catalog/progressindicator/res/layout/cat_progress_indicator_wave_controls.xml @@ -15,14 +15,15 @@ ~ limitations under the License. --> + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:clipChildren="false" + android:clipToPadding="false" + android:orientation="vertical" + android:padding="16dp" + android:showDividers="middle" + android:divider="@drawable/layout_divider"> + + + +