mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-13 17:37:16 +01:00
77 lines
2.8 KiB
Java
77 lines
2.8 KiB
Java
package com.google.android.material.motion;
|
|
|
|
import android.animation.TimeInterpolator;
|
|
import android.content.Context;
|
|
import android.util.Log;
|
|
import android.view.View;
|
|
import android.view.animation.PathInterpolator;
|
|
import androidx.activity.BackEventCompat;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RestrictTo;
|
|
import com.google.android.material.R;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
/* loaded from: classes7.dex */
|
|
public abstract class MaterialBackAnimationHelper<V extends View> {
|
|
private static final int CANCEL_DURATION_DEFAULT = 100;
|
|
private static final int HIDE_DURATION_MAX_DEFAULT = 300;
|
|
private static final int HIDE_DURATION_MIN_DEFAULT = 150;
|
|
private static final String TAG = "MaterialBackHelper";
|
|
|
|
@Nullable
|
|
private BackEventCompat backEvent;
|
|
protected final int cancelDuration;
|
|
protected final int hideDurationMax;
|
|
protected final int hideDurationMin;
|
|
|
|
@NonNull
|
|
private final TimeInterpolator progressInterpolator = new PathInterpolator(0.1f, 0.1f, 0.0f, 1.0f);
|
|
|
|
@NonNull
|
|
protected final V view;
|
|
|
|
public MaterialBackAnimationHelper(@NonNull V v) {
|
|
this.view = v;
|
|
Context context = v.getContext();
|
|
this.hideDurationMax = MotionUtils.resolveThemeDuration(context, R.attr.motionDurationMedium2, 300);
|
|
this.hideDurationMin = MotionUtils.resolveThemeDuration(context, R.attr.motionDurationShort3, 150);
|
|
this.cancelDuration = MotionUtils.resolveThemeDuration(context, R.attr.motionDurationShort2, 100);
|
|
}
|
|
|
|
public float interpolateProgress(float f) {
|
|
return this.progressInterpolator.getInterpolation(f);
|
|
}
|
|
|
|
@Nullable
|
|
public BackEventCompat onCancelBackProgress() {
|
|
if (this.backEvent == null) {
|
|
Log.w(TAG, "Must call startBackProgress() and updateBackProgress() before cancelBackProgress()");
|
|
}
|
|
BackEventCompat backEventCompat = this.backEvent;
|
|
this.backEvent = null;
|
|
return backEventCompat;
|
|
}
|
|
|
|
@Nullable
|
|
public BackEventCompat onHandleBackInvoked() {
|
|
BackEventCompat backEventCompat = this.backEvent;
|
|
this.backEvent = null;
|
|
return backEventCompat;
|
|
}
|
|
|
|
public void onStartBackProgress(@NonNull BackEventCompat backEventCompat) {
|
|
this.backEvent = backEventCompat;
|
|
}
|
|
|
|
@Nullable
|
|
public BackEventCompat onUpdateBackProgress(@NonNull BackEventCompat backEventCompat) {
|
|
if (this.backEvent == null) {
|
|
Log.w(TAG, "Must call startBackProgress() before updateBackProgress()");
|
|
}
|
|
BackEventCompat backEventCompat2 = this.backEvent;
|
|
this.backEvent = backEventCompat;
|
|
return backEventCompat2;
|
|
}
|
|
}
|