201 lines
6.6 KiB
Java
201 lines
6.6 KiB
Java
package androidx.appcompat.widget;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.Configuration;
|
|
import android.content.res.TypedArray;
|
|
import android.util.AttributeSet;
|
|
import android.util.TypedValue;
|
|
import android.view.ContextThemeWrapper;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import androidx.appcompat.R$attr;
|
|
import androidx.appcompat.R$styleable;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.core.view.ViewPropertyAnimatorCompat;
|
|
import androidx.core.view.ViewPropertyAnimatorListener;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public abstract class AbsActionBarView extends ViewGroup {
|
|
protected final VisibilityAnimListener a;
|
|
protected final Context b;
|
|
protected ActionMenuView c;
|
|
protected ActionMenuPresenter d;
|
|
protected int e;
|
|
protected ViewPropertyAnimatorCompat f;
|
|
private boolean g;
|
|
private boolean h;
|
|
|
|
AbsActionBarView(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
protected static int a(int i, int i2, boolean z) {
|
|
return z ? i - i2 : i + i2;
|
|
}
|
|
|
|
public int getAnimatedVisibility() {
|
|
return this.f != null ? this.a.b : getVisibility();
|
|
}
|
|
|
|
public int getContentHeight() {
|
|
return this.e;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onConfigurationChanged(Configuration configuration) {
|
|
super.onConfigurationChanged(configuration);
|
|
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(null, R$styleable.ActionBar, R$attr.actionBarStyle, 0);
|
|
setContentHeight(obtainStyledAttributes.getLayoutDimension(R$styleable.ActionBar_height, 0));
|
|
obtainStyledAttributes.recycle();
|
|
ActionMenuPresenter actionMenuPresenter = this.d;
|
|
if (actionMenuPresenter != null) {
|
|
actionMenuPresenter.a(configuration);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean onHoverEvent(MotionEvent motionEvent) {
|
|
int actionMasked = motionEvent.getActionMasked();
|
|
if (actionMasked == 9) {
|
|
this.h = false;
|
|
}
|
|
if (!this.h) {
|
|
boolean onHoverEvent = super.onHoverEvent(motionEvent);
|
|
if (actionMasked == 9 && !onHoverEvent) {
|
|
this.h = true;
|
|
}
|
|
}
|
|
if (actionMasked == 10 || actionMasked == 3) {
|
|
this.h = false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
|
int actionMasked = motionEvent.getActionMasked();
|
|
if (actionMasked == 0) {
|
|
this.g = false;
|
|
}
|
|
if (!this.g) {
|
|
boolean onTouchEvent = super.onTouchEvent(motionEvent);
|
|
if (actionMasked == 0 && !onTouchEvent) {
|
|
this.g = true;
|
|
}
|
|
}
|
|
if (actionMasked == 1 || actionMasked == 3) {
|
|
this.g = false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public abstract void setContentHeight(int i);
|
|
|
|
@Override // android.view.View
|
|
public void setVisibility(int i) {
|
|
if (i != getVisibility()) {
|
|
ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = this.f;
|
|
if (viewPropertyAnimatorCompat != null) {
|
|
viewPropertyAnimatorCompat.a();
|
|
}
|
|
super.setVisibility(i);
|
|
}
|
|
}
|
|
|
|
protected class VisibilityAnimListener implements ViewPropertyAnimatorListener {
|
|
private boolean a = false;
|
|
int b;
|
|
|
|
protected VisibilityAnimListener() {
|
|
}
|
|
|
|
public VisibilityAnimListener a(ViewPropertyAnimatorCompat viewPropertyAnimatorCompat, int i) {
|
|
AbsActionBarView.this.f = viewPropertyAnimatorCompat;
|
|
this.b = i;
|
|
return this;
|
|
}
|
|
|
|
@Override // androidx.core.view.ViewPropertyAnimatorListener
|
|
public void b(View view) {
|
|
if (this.a) {
|
|
return;
|
|
}
|
|
AbsActionBarView absActionBarView = AbsActionBarView.this;
|
|
absActionBarView.f = null;
|
|
AbsActionBarView.super.setVisibility(this.b);
|
|
}
|
|
|
|
@Override // androidx.core.view.ViewPropertyAnimatorListener
|
|
public void c(View view) {
|
|
AbsActionBarView.super.setVisibility(0);
|
|
this.a = false;
|
|
}
|
|
|
|
@Override // androidx.core.view.ViewPropertyAnimatorListener
|
|
public void a(View view) {
|
|
this.a = true;
|
|
}
|
|
}
|
|
|
|
AbsActionBarView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public ViewPropertyAnimatorCompat a(int i, long j) {
|
|
ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = this.f;
|
|
if (viewPropertyAnimatorCompat != null) {
|
|
viewPropertyAnimatorCompat.a();
|
|
}
|
|
if (i != 0) {
|
|
ViewPropertyAnimatorCompat a = ViewCompat.a(this);
|
|
a.a(0.0f);
|
|
a.a(j);
|
|
VisibilityAnimListener visibilityAnimListener = this.a;
|
|
visibilityAnimListener.a(a, i);
|
|
a.a(visibilityAnimListener);
|
|
return a;
|
|
}
|
|
if (getVisibility() != 0) {
|
|
setAlpha(0.0f);
|
|
}
|
|
ViewPropertyAnimatorCompat a2 = ViewCompat.a(this);
|
|
a2.a(1.0f);
|
|
a2.a(j);
|
|
VisibilityAnimListener visibilityAnimListener2 = this.a;
|
|
visibilityAnimListener2.a(a2, i);
|
|
a2.a(visibilityAnimListener2);
|
|
return a2;
|
|
}
|
|
|
|
AbsActionBarView(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
int i2;
|
|
this.a = new VisibilityAnimListener();
|
|
TypedValue typedValue = new TypedValue();
|
|
if (context.getTheme().resolveAttribute(R$attr.actionBarPopupTheme, typedValue, true) && (i2 = typedValue.resourceId) != 0) {
|
|
this.b = new ContextThemeWrapper(context, i2);
|
|
} else {
|
|
this.b = context;
|
|
}
|
|
}
|
|
|
|
protected int a(View view, int i, int i2, int i3) {
|
|
view.measure(View.MeasureSpec.makeMeasureSpec(i, Integer.MIN_VALUE), i2);
|
|
return Math.max(0, (i - view.getMeasuredWidth()) - i3);
|
|
}
|
|
|
|
protected int a(View view, int i, int i2, int i3, boolean z) {
|
|
int measuredWidth = view.getMeasuredWidth();
|
|
int measuredHeight = view.getMeasuredHeight();
|
|
int i4 = i2 + ((i3 - measuredHeight) / 2);
|
|
if (z) {
|
|
view.layout(i - measuredWidth, i4, i, measuredHeight + i4);
|
|
} else {
|
|
view.layout(i, i4, i + measuredWidth, measuredHeight + i4);
|
|
}
|
|
return z ? -measuredWidth : measuredWidth;
|
|
}
|
|
}
|