Skip to content

Commit

Permalink
[Carousel] Removed CenteredCarouselConfiguration.
Browse files Browse the repository at this point in the history
This removes CenteredCarouselConfigration and its superclass MultibrowseCarouselConfiguration and renames StartCarouselConfiguration to MultiBrowseCarouselConfiguration.

PiperOrigin-RevId: 506424085
  • Loading branch information
hunterstich authored and dsn5ft committed Feb 1, 2023
1 parent e2636ff commit ff48bc5
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 548 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.carousel.CarouselLayoutManager;
import com.google.android.material.carousel.CenteredCarouselConfiguration;
import io.material.catalog.feature.DemoFragment;

/** A fragment that displays the main Carousel demos for the Catalog app. */
/** A fragment that displays the main Carousel demo for the Catalog app. */
public class CarouselMainDemoFragment extends DemoFragment {

@NonNull
Expand All @@ -46,19 +45,16 @@ public View onCreateDemoView(
public void onViewCreated(@NonNull View view, @Nullable Bundle bundle) {
super.onViewCreated(view, bundle);

// A centered multi-browse carousel
RecyclerView multiBrowseCenteredRecyclerView =
view.findViewById(R.id.multi_browse_centered_carousel_recycler_view);
RecyclerView carouselRecyclerView =
view.findViewById(R.id.carousel_recycler_view);
CarouselLayoutManager multiBrowseCenteredCarouselLayoutManager = new CarouselLayoutManager();
multiBrowseCenteredCarouselLayoutManager.setCarouselConfiguration(
new CenteredCarouselConfiguration(multiBrowseCenteredCarouselLayoutManager));
multiBrowseCenteredRecyclerView.setLayoutManager(multiBrowseCenteredCarouselLayoutManager);
multiBrowseCenteredRecyclerView.setNestedScrollingEnabled(false);
carouselRecyclerView.setLayoutManager(multiBrowseCenteredCarouselLayoutManager);
carouselRecyclerView.setNestedScrollingEnabled(false);

CarouselAdapter adapter =
new CarouselAdapter(
(item, position) -> multiBrowseCenteredRecyclerView.scrollToPosition(position));
multiBrowseCenteredRecyclerView.setAdapter(adapter);
(item, position) -> carouselRecyclerView.scrollToPosition(position));
carouselRecyclerView.setAdapter(adapter);

adapter.submitList(CarouselData.createItems());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.carousel.CarouselLayoutManager;
import com.google.android.material.carousel.StartCarouselConfiguration;
import com.google.android.material.carousel.MultiBrowseCarouselConfiguration;
import com.google.android.material.materialswitch.MaterialSwitch;
import io.material.catalog.feature.DemoFragment;

Expand Down Expand Up @@ -55,8 +55,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle bundle) {
RecyclerView multiBrowseStartRecyclerView =
view.findViewById(R.id.multi_browse_start_carousel_recycler_view);
CarouselLayoutManager multiBrowseStartCarouselLayoutManager = new CarouselLayoutManager();
multiBrowseStartCarouselLayoutManager.setCarouselConfiguration(
new StartCarouselConfiguration(multiBrowseStartCarouselLayoutManager));
multiBrowseStartCarouselLayoutManager.setDrawDebugEnabled(
multiBrowseStartRecyclerView, debugSwitch.isChecked());
multiBrowseStartRecyclerView.setLayoutManager(multiBrowseStartCarouselLayoutManager);
Expand All @@ -73,7 +71,8 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle bundle) {
forceCompactSwitch.setOnCheckedChangeListener(
(buttonView, isChecked) ->
multiBrowseStartCarouselLayoutManager.setCarouselConfiguration(
new StartCarouselConfiguration(multiBrowseStartCarouselLayoutManager, isChecked)));
new MultiBrowseCarouselConfiguration(
multiBrowseStartCarouselLayoutManager, isChecked)));

CarouselAdapter adapter =
new CarouselAdapter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
android:orientation="vertical">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/multi_browse_centered_carousel_recycler_view"
android:id="@+id/carousel_recycler_view"
android:layout_width="match_parent"
android:layout_height="196dp"
android:layout_marginHorizontal="16dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private static final class ChildCalculations {
}

public CarouselLayoutManager() {
setCarouselConfiguration(new StartCarouselConfiguration(this));
setCarouselConfiguration(new MultiBrowseCarouselConfiguration(this));
}

public CarouselLayoutManager(
Expand Down

This file was deleted.

0 comments on commit ff48bc5

Please sign in to comment.