Skip to content

Commit

Permalink
make CircularRevealCardView extend MaterialCardView
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 233595839
  • Loading branch information
ymarian authored and afohrman committed Feb 24, 2019
1 parent 6f73e58 commit f42e432
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import io.material.catalog.R;

import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.transformation.TransformationChildCard;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.LayoutInflater;
Expand All @@ -45,7 +47,7 @@ public View onCreateDemoView(
Toolbar toolbar = view.findViewById(R.id.toolbar);
fab = view.findViewById(R.id.fab);
View closeButton = view.findViewById(R.id.close_button);
View sheet = view.findViewById(R.id.sheet);
TransformationChildCard sheet = view.findViewById(R.id.sheet);
View scrim = view.findViewById(R.id.scrim);

((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
Expand All @@ -55,6 +57,18 @@ public View onCreateDemoView(
scrim.setOnClickListener(v -> fab.setExpanded(false));

DraggableCoordinatorLayout container = (DraggableCoordinatorLayout) view;
container.setViewDragListener(new DraggableCoordinatorLayout.ViewDragListener() {
@Override
public void onViewCaptured(@NonNull View view, int i) {
sheet.setDragged(true);
}

@Override
public void onViewReleased(@NonNull View view, float v, float v1) {
sheet.setDragged(false);
}
});

container.addDraggableChild(fab);
container.addDraggableChild(sheet);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,26 @@
android:layout_gravity="bottom|right"
android:visibility="invisible"
app:cardElevation="2dp"
app:contentPadding="20dp"
app:layout_behavior="@string/fab_transformation_sheet_behavior">

<ImageButton
android:id="@+id/close_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:padding="12dp"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/close_sheet"
android:scaleType="fitCenter"
android:tint="?attr/colorOnSurface"
app:srcCompat="@drawable/ic_close_vd_theme_24px"/>

<!-- TransformationChildCard can contain arbitrary content provided by the app. -->
<FrameLayout
android:padding="20dp"
android:layout_width="200dp"
android:layout_height="300dp">

<ImageButton
android:id="@+id/close_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:padding="12dp"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/close_sheet"
android:scaleType="fitCenter"
android:tint="?attr/colorOnSurface"
app:srcCompat="@drawable/ic_close_vd_theme_24px"/>

<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 @@ -20,15 +20,15 @@
import android.graphics.drawable.Drawable;
import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.circularreveal.CircularRevealHelper;
import com.google.android.material.circularreveal.CircularRevealWidget;
import android.util.AttributeSet;
import androidx.cardview.widget.CardView;

/**
* A CircularRevealWidget wrapper for {@link CardView}.
* A CircularRevealWidget wrapper for {@link MaterialCardView}.
*/
public class CircularRevealCardView extends CardView implements CircularRevealWidget {
public class CircularRevealCardView extends MaterialCardView implements CircularRevealWidget {

private final CircularRevealHelper helper;

Expand Down

0 comments on commit f42e432

Please sign in to comment.