Initial commit
This commit is contained in:
@@ -0,0 +1,669 @@
|
||||
package com.google.android.material.floatingactionbutton;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.appcompat.widget.AppCompatDrawableManager;
|
||||
import androidx.appcompat.widget.AppCompatImageHelper;
|
||||
import androidx.collection.SimpleArrayMap;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.TintableBackgroundView;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.widget.TintableImageSourceView;
|
||||
import com.google.android.material.R$dimen;
|
||||
import com.google.android.material.R$styleable;
|
||||
import com.google.android.material.animation.MotionSpec;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.expandable.ExpandableTransformationWidget;
|
||||
import com.google.android.material.expandable.ExpandableWidgetHelper;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButtonImpl;
|
||||
import com.google.android.material.internal.DescendantOffsetUtils;
|
||||
import com.google.android.material.internal.VisibilityAwareImageButton;
|
||||
import com.google.android.material.shadow.ShadowViewDelegate;
|
||||
import com.google.android.material.stateful.ExtendableSavedState;
|
||||
import java.util.List;
|
||||
|
||||
@CoordinatorLayout.DefaultBehavior(Behavior.class)
|
||||
/* loaded from: classes.dex */
|
||||
public class FloatingActionButton extends VisibilityAwareImageButton implements TintableBackgroundView, TintableImageSourceView, ExpandableTransformationWidget {
|
||||
private ColorStateList b;
|
||||
private PorterDuff.Mode c;
|
||||
private ColorStateList d;
|
||||
private PorterDuff.Mode e;
|
||||
private ColorStateList f;
|
||||
private int g;
|
||||
private int h;
|
||||
private int i;
|
||||
private int j;
|
||||
boolean k;
|
||||
final Rect l;
|
||||
private final Rect m;
|
||||
private final AppCompatImageHelper n;
|
||||
private final ExpandableWidgetHelper o;
|
||||
private FloatingActionButtonImpl p;
|
||||
|
||||
protected static class BaseBehavior<T extends FloatingActionButton> extends CoordinatorLayout.Behavior<T> {
|
||||
private Rect a;
|
||||
private OnVisibilityChangedListener b;
|
||||
private boolean c;
|
||||
|
||||
public BaseBehavior() {
|
||||
this.c = true;
|
||||
}
|
||||
|
||||
private boolean b(View view, FloatingActionButton floatingActionButton) {
|
||||
if (!a(view, floatingActionButton)) {
|
||||
return false;
|
||||
}
|
||||
if (view.getTop() < (floatingActionButton.getHeight() / 2) + ((ViewGroup.MarginLayoutParams) ((CoordinatorLayout.LayoutParams) floatingActionButton.getLayoutParams())).topMargin) {
|
||||
floatingActionButton.a(this.b, false);
|
||||
return true;
|
||||
}
|
||||
floatingActionButton.b(this.b, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
public BaseBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.FloatingActionButton_Behavior_Layout);
|
||||
this.c = obtainStyledAttributes.getBoolean(R$styleable.FloatingActionButton_Behavior_Layout_behavior_autoHide, true);
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public void a(CoordinatorLayout.LayoutParams layoutParams) {
|
||||
if (layoutParams.h == 0) {
|
||||
layoutParams.h = 80;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public boolean b(CoordinatorLayout coordinatorLayout, FloatingActionButton floatingActionButton, View view) {
|
||||
if (view instanceof AppBarLayout) {
|
||||
a(coordinatorLayout, (AppBarLayout) view, floatingActionButton);
|
||||
return false;
|
||||
}
|
||||
if (!a(view)) {
|
||||
return false;
|
||||
}
|
||||
b(view, floatingActionButton);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean a(View view) {
|
||||
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||||
if (layoutParams instanceof CoordinatorLayout.LayoutParams) {
|
||||
return ((CoordinatorLayout.LayoutParams) layoutParams).d() instanceof BottomSheetBehavior;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean a(View view, FloatingActionButton floatingActionButton) {
|
||||
return this.c && ((CoordinatorLayout.LayoutParams) floatingActionButton.getLayoutParams()).c() == view.getId() && floatingActionButton.getUserSetVisibility() == 0;
|
||||
}
|
||||
|
||||
private boolean a(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, FloatingActionButton floatingActionButton) {
|
||||
if (!a(appBarLayout, floatingActionButton)) {
|
||||
return false;
|
||||
}
|
||||
if (this.a == null) {
|
||||
this.a = new Rect();
|
||||
}
|
||||
Rect rect = this.a;
|
||||
DescendantOffsetUtils.a(coordinatorLayout, appBarLayout, rect);
|
||||
if (rect.bottom <= appBarLayout.getMinimumHeightForVisibleOverlappingContent()) {
|
||||
floatingActionButton.a(this.b, false);
|
||||
return true;
|
||||
}
|
||||
floatingActionButton.b(this.b, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean a(CoordinatorLayout coordinatorLayout, FloatingActionButton floatingActionButton, int i) {
|
||||
List<View> b = coordinatorLayout.b(floatingActionButton);
|
||||
int size = b.size();
|
||||
for (int i2 = 0; i2 < size; i2++) {
|
||||
View view = b.get(i2);
|
||||
if (view instanceof AppBarLayout) {
|
||||
if (a(coordinatorLayout, (AppBarLayout) view, floatingActionButton)) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (a(view) && b(view, floatingActionButton)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
coordinatorLayout.c(floatingActionButton, i);
|
||||
a(coordinatorLayout, floatingActionButton);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean a(CoordinatorLayout coordinatorLayout, FloatingActionButton floatingActionButton, Rect rect) {
|
||||
Rect rect2 = floatingActionButton.l;
|
||||
rect.set(floatingActionButton.getLeft() + rect2.left, floatingActionButton.getTop() + rect2.top, floatingActionButton.getRight() - rect2.right, floatingActionButton.getBottom() - rect2.bottom);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void a(CoordinatorLayout coordinatorLayout, FloatingActionButton floatingActionButton) {
|
||||
int i;
|
||||
Rect rect = floatingActionButton.l;
|
||||
if (rect == null || rect.centerX() <= 0 || rect.centerY() <= 0) {
|
||||
return;
|
||||
}
|
||||
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) floatingActionButton.getLayoutParams();
|
||||
int i2 = 0;
|
||||
if (floatingActionButton.getRight() >= coordinatorLayout.getWidth() - ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin) {
|
||||
i = rect.right;
|
||||
} else {
|
||||
i = floatingActionButton.getLeft() <= ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin ? -rect.left : 0;
|
||||
}
|
||||
if (floatingActionButton.getBottom() >= coordinatorLayout.getHeight() - ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin) {
|
||||
i2 = rect.bottom;
|
||||
} else if (floatingActionButton.getTop() <= ((ViewGroup.MarginLayoutParams) layoutParams).topMargin) {
|
||||
i2 = -rect.top;
|
||||
}
|
||||
if (i2 != 0) {
|
||||
ViewCompat.d((View) floatingActionButton, i2);
|
||||
}
|
||||
if (i != 0) {
|
||||
ViewCompat.c((View) floatingActionButton, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Behavior extends BaseBehavior<FloatingActionButton> {
|
||||
public Behavior() {
|
||||
}
|
||||
|
||||
public Behavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class OnVisibilityChangedListener {
|
||||
public abstract void a(FloatingActionButton floatingActionButton);
|
||||
|
||||
public abstract void b(FloatingActionButton floatingActionButton);
|
||||
}
|
||||
|
||||
private void c() {
|
||||
Drawable drawable = getDrawable();
|
||||
if (drawable == null) {
|
||||
return;
|
||||
}
|
||||
ColorStateList colorStateList = this.d;
|
||||
if (colorStateList == null) {
|
||||
DrawableCompat.b(drawable);
|
||||
return;
|
||||
}
|
||||
int colorForState = colorStateList.getColorForState(getDrawableState(), 0);
|
||||
PorterDuff.Mode mode = this.e;
|
||||
if (mode == null) {
|
||||
mode = PorterDuff.Mode.SRC_IN;
|
||||
}
|
||||
drawable.mutate().setColorFilter(AppCompatDrawableManager.a(colorForState, mode));
|
||||
}
|
||||
|
||||
private FloatingActionButtonImpl getImpl() {
|
||||
if (this.p == null) {
|
||||
this.p = b();
|
||||
}
|
||||
return this.p;
|
||||
}
|
||||
|
||||
void b(OnVisibilityChangedListener onVisibilityChangedListener, boolean z) {
|
||||
getImpl().b(a(onVisibilityChangedListener), z);
|
||||
}
|
||||
|
||||
public void d(Animator.AnimatorListener animatorListener) {
|
||||
getImpl().d(animatorListener);
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void drawableStateChanged() {
|
||||
super.drawableStateChanged();
|
||||
getImpl().a(getDrawableState());
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public ColorStateList getBackgroundTintList() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public PorterDuff.Mode getBackgroundTintMode() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public float getCompatElevation() {
|
||||
return getImpl().b();
|
||||
}
|
||||
|
||||
public float getCompatHoveredFocusedTranslationZ() {
|
||||
return getImpl().d();
|
||||
}
|
||||
|
||||
public float getCompatPressedTranslationZ() {
|
||||
return getImpl().e();
|
||||
}
|
||||
|
||||
public Drawable getContentBackground() {
|
||||
return getImpl().a();
|
||||
}
|
||||
|
||||
public int getCustomSize() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
public int getExpandedComponentIdHint() {
|
||||
this.o.a();
|
||||
throw null;
|
||||
}
|
||||
|
||||
public MotionSpec getHideMotionSpec() {
|
||||
return getImpl().c();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getRippleColor() {
|
||||
ColorStateList colorStateList = this.f;
|
||||
if (colorStateList != null) {
|
||||
return colorStateList.getDefaultColor();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ColorStateList getRippleColorStateList() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public MotionSpec getShowMotionSpec() {
|
||||
return getImpl().f();
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
int getSizeDimension() {
|
||||
return a(this.g);
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.TintableBackgroundView
|
||||
public ColorStateList getSupportBackgroundTintList() {
|
||||
return getBackgroundTintList();
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.TintableBackgroundView
|
||||
public PorterDuff.Mode getSupportBackgroundTintMode() {
|
||||
return getBackgroundTintMode();
|
||||
}
|
||||
|
||||
@Override // androidx.core.widget.TintableImageSourceView
|
||||
public ColorStateList getSupportImageTintList() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
@Override // androidx.core.widget.TintableImageSourceView
|
||||
public PorterDuff.Mode getSupportImageTintMode() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public boolean getUseCompatPadding() {
|
||||
return this.k;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.expandable.ExpandableWidget
|
||||
public boolean isExpanded() {
|
||||
this.o.b();
|
||||
throw null;
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
public void jumpDrawablesToCurrentState() {
|
||||
super.jumpDrawablesToCurrentState();
|
||||
getImpl().i();
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
getImpl().j();
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
getImpl().l();
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
int sizeDimension = getSizeDimension();
|
||||
this.i = (sizeDimension - this.j) / 2;
|
||||
getImpl().p();
|
||||
int min = Math.min(a(sizeDimension, i), a(sizeDimension, i2));
|
||||
Rect rect = this.l;
|
||||
setMeasuredDimension(rect.left + min + rect.right, min + rect.top + rect.bottom);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onRestoreInstanceState(Parcelable parcelable) {
|
||||
if (!(parcelable instanceof ExtendableSavedState)) {
|
||||
super.onRestoreInstanceState(parcelable);
|
||||
return;
|
||||
}
|
||||
ExtendableSavedState extendableSavedState = (ExtendableSavedState) parcelable;
|
||||
super.onRestoreInstanceState(extendableSavedState.getSuperState());
|
||||
this.o.a(extendableSavedState.extendableStates.get("expandableWidgetHelper"));
|
||||
throw null;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
SimpleArrayMap<String, Bundle> simpleArrayMap = new ExtendableSavedState(super.onSaveInstanceState()).extendableStates;
|
||||
this.o.c();
|
||||
throw null;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
if (motionEvent.getAction() == 0 && a(this.m) && !this.m.contains((int) motionEvent.getX(), (int) motionEvent.getY())) {
|
||||
return false;
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundColor(int i) {
|
||||
Log.i("FloatingActionButton", "Setting a custom background is not supported.");
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundDrawable(Drawable drawable) {
|
||||
Log.i("FloatingActionButton", "Setting a custom background is not supported.");
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundResource(int i) {
|
||||
Log.i("FloatingActionButton", "Setting a custom background is not supported.");
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundTintList(ColorStateList colorStateList) {
|
||||
if (this.b != colorStateList) {
|
||||
this.b = colorStateList;
|
||||
getImpl().a(colorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setBackgroundTintMode(PorterDuff.Mode mode) {
|
||||
if (this.c != mode) {
|
||||
this.c = mode;
|
||||
getImpl().a(mode);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCompatElevation(float f) {
|
||||
getImpl().a(f);
|
||||
}
|
||||
|
||||
public void setCompatElevationResource(int i) {
|
||||
setCompatElevation(getResources().getDimension(i));
|
||||
}
|
||||
|
||||
public void setCompatHoveredFocusedTranslationZ(float f) {
|
||||
getImpl().b(f);
|
||||
}
|
||||
|
||||
public void setCompatHoveredFocusedTranslationZResource(int i) {
|
||||
setCompatHoveredFocusedTranslationZ(getResources().getDimension(i));
|
||||
}
|
||||
|
||||
public void setCompatPressedTranslationZ(float f) {
|
||||
getImpl().d(f);
|
||||
}
|
||||
|
||||
public void setCompatPressedTranslationZResource(int i) {
|
||||
setCompatPressedTranslationZ(getResources().getDimension(i));
|
||||
}
|
||||
|
||||
public void setCustomSize(int i) {
|
||||
if (i < 0) {
|
||||
throw new IllegalArgumentException("Custom size must be non-negative");
|
||||
}
|
||||
this.h = i;
|
||||
}
|
||||
|
||||
public void setExpandedComponentIdHint(int i) {
|
||||
this.o.a(i);
|
||||
throw null;
|
||||
}
|
||||
|
||||
public void setHideMotionSpec(MotionSpec motionSpec) {
|
||||
getImpl().a(motionSpec);
|
||||
}
|
||||
|
||||
public void setHideMotionSpecResource(int i) {
|
||||
setHideMotionSpec(MotionSpec.a(getContext(), i));
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView
|
||||
public void setImageDrawable(Drawable drawable) {
|
||||
super.setImageDrawable(drawable);
|
||||
getImpl().o();
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView
|
||||
public void setImageResource(int i) {
|
||||
this.n.a(i);
|
||||
}
|
||||
|
||||
public void setRippleColor(int i) {
|
||||
setRippleColor(ColorStateList.valueOf(i));
|
||||
}
|
||||
|
||||
public void setShowMotionSpec(MotionSpec motionSpec) {
|
||||
getImpl().b(motionSpec);
|
||||
}
|
||||
|
||||
public void setShowMotionSpecResource(int i) {
|
||||
setShowMotionSpec(MotionSpec.a(getContext(), i));
|
||||
}
|
||||
|
||||
public void setSize(int i) {
|
||||
this.h = 0;
|
||||
if (i != this.g) {
|
||||
this.g = i;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.TintableBackgroundView
|
||||
public void setSupportBackgroundTintList(ColorStateList colorStateList) {
|
||||
setBackgroundTintList(colorStateList);
|
||||
}
|
||||
|
||||
@Override // androidx.core.view.TintableBackgroundView
|
||||
public void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
|
||||
setBackgroundTintMode(mode);
|
||||
}
|
||||
|
||||
@Override // androidx.core.widget.TintableImageSourceView
|
||||
public void setSupportImageTintList(ColorStateList colorStateList) {
|
||||
if (this.d != colorStateList) {
|
||||
this.d = colorStateList;
|
||||
c();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.core.widget.TintableImageSourceView
|
||||
public void setSupportImageTintMode(PorterDuff.Mode mode) {
|
||||
if (this.e != mode) {
|
||||
this.e = mode;
|
||||
c();
|
||||
}
|
||||
}
|
||||
|
||||
public void setUseCompatPadding(boolean z) {
|
||||
if (this.k != z) {
|
||||
this.k = z;
|
||||
getImpl().k();
|
||||
}
|
||||
}
|
||||
|
||||
public void b(Animator.AnimatorListener animatorListener) {
|
||||
getImpl().b(animatorListener);
|
||||
}
|
||||
|
||||
public void setRippleColor(ColorStateList colorStateList) {
|
||||
if (this.f != colorStateList) {
|
||||
this.f = colorStateList;
|
||||
getImpl().b(this.f);
|
||||
}
|
||||
}
|
||||
|
||||
void a(OnVisibilityChangedListener onVisibilityChangedListener, boolean z) {
|
||||
getImpl().a(a(onVisibilityChangedListener), z);
|
||||
}
|
||||
|
||||
public void b(Rect rect) {
|
||||
rect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
|
||||
c(rect);
|
||||
}
|
||||
|
||||
private class ShadowDelegateImpl implements ShadowViewDelegate {
|
||||
ShadowDelegateImpl() {
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shadow.ShadowViewDelegate
|
||||
public void a(int i, int i2, int i3, int i4) {
|
||||
FloatingActionButton.this.l.set(i, i2, i3, i4);
|
||||
FloatingActionButton floatingActionButton = FloatingActionButton.this;
|
||||
floatingActionButton.setPadding(i + floatingActionButton.i, i2 + FloatingActionButton.this.i, i3 + FloatingActionButton.this.i, i4 + FloatingActionButton.this.i);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shadow.ShadowViewDelegate
|
||||
public float b() {
|
||||
return FloatingActionButton.this.getSizeDimension() / 2.0f;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shadow.ShadowViewDelegate
|
||||
public void a(Drawable drawable) {
|
||||
FloatingActionButton.super.setBackgroundDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shadow.ShadowViewDelegate
|
||||
public boolean a() {
|
||||
return FloatingActionButton.this.k;
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Animator.AnimatorListener animatorListener) {
|
||||
getImpl().a(animatorListener);
|
||||
}
|
||||
|
||||
private FloatingActionButtonImpl.InternalVisibilityChangedListener a(final OnVisibilityChangedListener onVisibilityChangedListener) {
|
||||
if (onVisibilityChangedListener == null) {
|
||||
return null;
|
||||
}
|
||||
return new FloatingActionButtonImpl.InternalVisibilityChangedListener() { // from class: com.google.android.material.floatingactionbutton.FloatingActionButton.1
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl.InternalVisibilityChangedListener
|
||||
public void a() {
|
||||
onVisibilityChangedListener.b(FloatingActionButton.this);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.floatingactionbutton.FloatingActionButtonImpl.InternalVisibilityChangedListener
|
||||
public void b() {
|
||||
onVisibilityChangedListener.a(FloatingActionButton.this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private FloatingActionButtonImpl b() {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return new FloatingActionButtonImplLollipop(this, new ShadowDelegateImpl());
|
||||
}
|
||||
return new FloatingActionButtonImpl(this, new ShadowDelegateImpl());
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
return getImpl().h();
|
||||
}
|
||||
|
||||
private int a(int i) {
|
||||
int i2 = this.h;
|
||||
if (i2 != 0) {
|
||||
return i2;
|
||||
}
|
||||
Resources resources = getResources();
|
||||
if (i != -1) {
|
||||
if (i != 1) {
|
||||
return resources.getDimensionPixelSize(R$dimen.design_fab_size_normal);
|
||||
}
|
||||
return resources.getDimensionPixelSize(R$dimen.design_fab_size_mini);
|
||||
}
|
||||
if (Math.max(resources.getConfiguration().screenWidthDp, resources.getConfiguration().screenHeightDp) < 470) {
|
||||
return a(1);
|
||||
}
|
||||
return a(0);
|
||||
}
|
||||
|
||||
public void c(Animator.AnimatorListener animatorListener) {
|
||||
getImpl().c(animatorListener);
|
||||
}
|
||||
|
||||
private void c(Rect rect) {
|
||||
int i = rect.left;
|
||||
Rect rect2 = this.l;
|
||||
rect.left = i + rect2.left;
|
||||
rect.top += rect2.top;
|
||||
rect.right -= rect2.right;
|
||||
rect.bottom -= rect2.bottom;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean a(Rect rect) {
|
||||
if (!ViewCompat.x(this)) {
|
||||
return false;
|
||||
}
|
||||
rect.set(0, 0, getWidth(), getHeight());
|
||||
c(rect);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int a(int i, int i2) {
|
||||
int mode = View.MeasureSpec.getMode(i2);
|
||||
int size = View.MeasureSpec.getSize(i2);
|
||||
if (mode == Integer.MIN_VALUE) {
|
||||
return Math.min(i, size);
|
||||
}
|
||||
if (mode == 0) {
|
||||
return i;
|
||||
}
|
||||
if (mode == 1073741824) {
|
||||
return size;
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user