Skip to content

Commit

Permalink
[Predictive Back] Make back helpers support generified View type
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 523442268
  • Loading branch information
dsn5ft authored and drchen committed Apr 13, 2023
1 parent 77cdc1e commit 69b5386
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Expand Up @@ -25,29 +25,34 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.core.view.animation.PathInterpolatorCompat;
import com.google.errorprone.annotations.CanIgnoreReturnValue;

/**
* Base helper class for views that support back handling, which assists with common animation
* details and back event validation.
*
* @hide
*/
abstract class MaterialBackAnimationHelper {
@RestrictTo(Scope.LIBRARY_GROUP)
public abstract class MaterialBackAnimationHelper<V extends View> {

private static final int HIDE_DURATION_MAX_DEFAULT = 300;
private static final int HIDE_DURATION_MIN_DEFAULT = 150;
private static final int CANCEL_DURATION_DEFAULT = 100;

@NonNull private final TimeInterpolator progressInterpolator;

@NonNull protected final View view;
@NonNull protected final V view;
protected final int hideDurationMax;
protected final int hideDurationMin;
protected final int cancelDuration;

@Nullable private BackEvent backEvent;

public MaterialBackAnimationHelper(@NonNull View view) {
public MaterialBackAnimationHelper(@NonNull V view) {
this.view = view;

Context context = view.getContext();
Expand Down
Expand Up @@ -44,7 +44,7 @@
* @hide
*/
@RestrictTo(LIBRARY_GROUP)
public class MaterialBottomContainerBackHelper extends MaterialBackAnimationHelper {
public class MaterialBottomContainerBackHelper extends MaterialBackAnimationHelper<View> {

private final float maxScaleXDistance;
private final float maxScaleYDistance;
Expand Down
Expand Up @@ -51,7 +51,7 @@
* @hide
*/
@RestrictTo(LIBRARY_GROUP)
public class MaterialMainContainerBackHelper extends MaterialBackAnimationHelper {
public class MaterialMainContainerBackHelper extends MaterialBackAnimationHelper<View> {

private static final float MIN_SCALE = 0.9f;

Expand Down
Expand Up @@ -49,7 +49,7 @@
* @hide
*/
@RestrictTo(LIBRARY_GROUP)
public class MaterialSideContainerBackHelper extends MaterialBackAnimationHelper {
public class MaterialSideContainerBackHelper extends MaterialBackAnimationHelper<View> {

private final float maxScaleXDistanceShrink;
private final float maxScaleXDistanceGrow;
Expand Down

0 comments on commit 69b5386

Please sign in to comment.