diff --git a/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorDeterminateDemoFragment.java b/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorDeterminateDemoFragment.java deleted file mode 100644 index 7fb00a6719a..00000000000 --- a/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorDeterminateDemoFragment.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.material.catalog.progressindicator; - -import io.material.catalog.R; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.google.android.material.progressindicator.CircularProgressIndicator; -import com.google.android.material.progressindicator.LinearProgressIndicator; -import com.google.android.material.slider.Slider; -import io.material.catalog.feature.DemoFragment; -import io.material.catalog.feature.DemoUtils; -import java.util.List; - -/** - * This is the fragment to dome in details of different determinate progress indicators. - * - *

This demo includes multiple examples of determinate {@link LinearProgressIndicator} and {@link - * CircularProgressIndicator} and the ability to: - * - *

- */ -public class ProgressIndicatorDeterminateDemoFragment extends DemoFragment { - - @Override - @NonNull - public View onCreateDemoView( - @NonNull LayoutInflater layoutInflater, - @Nullable ViewGroup viewGroup, - @Nullable Bundle bundle) { - View view = - layoutInflater.inflate( - R.layout.cat_progress_indicator_determinate_fragment, - viewGroup, - false /* attachToRoot */); - - initialize(view); - - return view; - } - - public void initialize(@NonNull View view) { - List linearProgressIndicatorList = - DemoUtils.findViewsWithType(view, LinearProgressIndicator.class); - List circularProgressIndicatorList = - DemoUtils.findViewsWithType(view, CircularProgressIndicator.class); - - Slider slider = view.findViewById(R.id.slider); - Button showButton = view.findViewById(R.id.show_button); - Button hideButton = view.findViewById(R.id.hide_button); - - slider.addOnChangeListener( - (sliderObj, value, fromUser) -> { - for (LinearProgressIndicator indicator : linearProgressIndicatorList) { - indicator.setProgressCompat((int) value, true); - } - for (CircularProgressIndicator indicator : circularProgressIndicatorList) { - indicator.setProgressCompat((int) value, true); - } - }); - showButton.setOnClickListener( - v -> { - for (LinearProgressIndicator indicator : linearProgressIndicatorList) { - indicator.show(); - } - for (CircularProgressIndicator indicator : circularProgressIndicatorList) { - indicator.show(); - } - }); - hideButton.setOnClickListener( - v -> { - for (LinearProgressIndicator indicator : linearProgressIndicatorList) { - indicator.hide(); - } - for (CircularProgressIndicator indicator : circularProgressIndicatorList) { - indicator.hide(); - } - }); - } -} diff --git a/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorFragment.java b/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorFragment.java index 069154353da..f280620d37b 100644 --- a/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorFragment.java +++ b/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorFragment.java @@ -65,6 +65,13 @@ public Fragment createFragment() { return new ProgressIndicatorVisibilityDemoFragment(); } }); + additionalDemos.add( + new Demo(R.string.cat_progress_indicator_demo_standalone_title) { + @Override + public Fragment createFragment() { + return new ProgressIndicatorStandaloneDemoFragment(); + } + }); return additionalDemos; } @@ -80,29 +87,9 @@ public Fragment createFragment() { return new ProgressIndicatorMultiColorDemoFragment(); } }); - additionalDemos.add( - new Demo(R.string.cat_progress_indicator_demo_indeterminate_title) { - @Override - public Fragment createFragment() { - return new ProgressIndicatorIndeterminateDemoFragment(); - } - }); - additionalDemos.add( - new Demo(R.string.cat_progress_indicator_demo_determinate_title) { - @Override - public Fragment createFragment() { - return new ProgressIndicatorDeterminateDemoFragment(); - } - }); - additionalDemos.add( - new Demo(R.string.cat_progress_indicator_demo_standalone_title) { - @Override - public Fragment createFragment() { - return new ProgressIndicatorStandaloneDemoFragment(); - } - }); return additionalDemos; } + /** The Dagger module for {@link ProgressIndicatorFragment} dependencies. */ @dagger.Module public abstract static class Module { diff --git a/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorIndeterminateDemoFragment.java b/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorIndeterminateDemoFragment.java deleted file mode 100644 index 4553d811905..00000000000 --- a/catalog/java/io/material/catalog/progressindicator/ProgressIndicatorIndeterminateDemoFragment.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.material.catalog.progressindicator; - -import io.material.catalog.R; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.EditText; -import androidx.annotation.LayoutRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.google.android.material.progressindicator.CircularProgressIndicator; -import com.google.android.material.progressindicator.LinearProgressIndicator; -import io.material.catalog.feature.DemoFragment; -import io.material.catalog.feature.DemoUtils; -import java.util.List; - -/** - * This is the fragment to demo in details of different indeterminate progress indicators. - * - *

This demo includes multiple examples of indeterminate {@link LinearProgressIndicator} and - * {@link CircularProgressIndicator} and the ability to: - * - *

- */ -public class ProgressIndicatorIndeterminateDemoFragment extends DemoFragment { - - @Override - @NonNull - public View onCreateDemoView( - @NonNull LayoutInflater layoutInflater, - @Nullable ViewGroup viewGroup, - @Nullable Bundle bundle) { - View view = - layoutInflater.inflate( - R.layout.cat_progress_indicator_indeterminate_fragment, - viewGroup, - false /* attachToRoot */); - - ViewGroup content = view.findViewById(R.id.content); - content.addView(layoutInflater.inflate(getIndicatorsContent(), content, false), 0); - - initialize(view); - - return view; - } - - /** Layout resource containing the progress indicator examples. */ - @LayoutRes - protected int getIndicatorsContent() { - return R.layout.cat_progress_indicator_indeterminate_indicators; - } - - /** - * Updates the linear progress indicator to show the specified progress. This is called every time - * the "update" button is pressed. - */ - protected void updateLinearProgressIndicator( - @NonNull LinearProgressIndicator linearProgressIndicator, int progress) { - linearProgressIndicator.setProgressCompat(progress, /*animated=*/ true); - } - - /** - * Updates the circular progress indicator to show the specified progress. This is called every - * time the "update" button is pressed. - */ - protected void updateCircularProgressIndicator( - @NonNull CircularProgressIndicator circularProgressIndicator, int progress) { - circularProgressIndicator.setProgressCompat(progress, /*animated=*/ true); - } - - private void initialize(View view) { - List linearProgressIndicatorList = - DemoUtils.findViewsWithType(view, LinearProgressIndicator.class); - List circularProgressIndicatorList = - DemoUtils.findViewsWithType(view, CircularProgressIndicator.class); - - EditText progressInput = view.findViewById(R.id.progress_input); - Button updateButton = view.findViewById(R.id.update_button); - Button showButton = view.findViewById(R.id.show_button); - Button hideButton = view.findViewById(R.id.hide_button); - - updateButton.setOnClickListener( - v -> { - int progress; - try { - progress = Integer.parseInt(progressInput.getEditableText().toString()); - } catch (NumberFormatException e) { - progress = 0; - } - for (LinearProgressIndicator indicator : linearProgressIndicatorList) { - updateLinearProgressIndicator(indicator, progress); - } - for (CircularProgressIndicator indicator : circularProgressIndicatorList) { - updateCircularProgressIndicator(indicator, progress); - } - }); - showButton.setOnClickListener( - v -> { - for (LinearProgressIndicator indicator : linearProgressIndicatorList) { - indicator.setIndeterminate(true); - indicator.show(); - } - for (CircularProgressIndicator indicator : circularProgressIndicatorList) { - indicator.setIndeterminate(true); - indicator.show(); - } - }); - hideButton.setOnClickListener( - v -> { - for (LinearProgressIndicator indicator : linearProgressIndicatorList) { - indicator.hide(); - } - for (CircularProgressIndicator indicator : circularProgressIndicatorList) { - indicator.hide(); - } - }); - } -} diff --git a/catalog/java/io/material/catalog/progressindicator/res/layout/cat_progress_indicator_determinate_fragment.xml b/catalog/java/io/material/catalog/progressindicator/res/layout/cat_progress_indicator_determinate_fragment.xml deleted file mode 100644 index c4bb00230cd..00000000000 --- a/catalog/java/io/material/catalog/progressindicator/res/layout/cat_progress_indicator_determinate_fragment.xml +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -