ADD week 5
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,269 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.widget.OverScroller;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.math.MathUtils;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class HeaderBehavior<V extends View> extends ViewOffsetBehavior<V> {
|
||||
private static final int INVALID_POINTER = -1;
|
||||
private int activePointerId;
|
||||
private Runnable flingRunnable;
|
||||
private boolean isBeingDragged;
|
||||
private int lastMotionY;
|
||||
OverScroller scroller;
|
||||
private int touchSlop;
|
||||
private VelocityTracker velocityTracker;
|
||||
|
||||
boolean canDragView(V v) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void onFlingFinished(CoordinatorLayout coordinatorLayout, V v) {
|
||||
}
|
||||
|
||||
public HeaderBehavior() {
|
||||
this.activePointerId = -1;
|
||||
this.touchSlop = -1;
|
||||
}
|
||||
|
||||
public HeaderBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.activePointerId = -1;
|
||||
this.touchSlop = -1;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onInterceptTouchEvent(CoordinatorLayout coordinatorLayout, V v, MotionEvent motionEvent) {
|
||||
int findPointerIndex;
|
||||
if (this.touchSlop < 0) {
|
||||
this.touchSlop = ViewConfiguration.get(coordinatorLayout.getContext()).getScaledTouchSlop();
|
||||
}
|
||||
if (motionEvent.getActionMasked() == 2 && this.isBeingDragged) {
|
||||
int i = this.activePointerId;
|
||||
if (i == -1 || (findPointerIndex = motionEvent.findPointerIndex(i)) == -1) {
|
||||
return false;
|
||||
}
|
||||
int y = (int) motionEvent.getY(findPointerIndex);
|
||||
if (Math.abs(y - this.lastMotionY) > this.touchSlop) {
|
||||
this.lastMotionY = y;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (motionEvent.getActionMasked() == 0) {
|
||||
this.activePointerId = -1;
|
||||
int x = (int) motionEvent.getX();
|
||||
int y2 = (int) motionEvent.getY();
|
||||
boolean z = canDragView(v) && coordinatorLayout.isPointInChildBounds(v, x, y2);
|
||||
this.isBeingDragged = z;
|
||||
if (z) {
|
||||
this.lastMotionY = y2;
|
||||
this.activePointerId = motionEvent.getPointerId(0);
|
||||
ensureVelocityTracker();
|
||||
OverScroller overScroller = this.scroller;
|
||||
if (overScroller != null && !overScroller.isFinished()) {
|
||||
this.scroller.abortAnimation();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
VelocityTracker velocityTracker = this.velocityTracker;
|
||||
if (velocityTracker != null) {
|
||||
velocityTracker.addMovement(motionEvent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:17:0x0085 */
|
||||
/* JADX WARN: Removed duplicated region for block: B:20:0x008c A[ADDED_TO_REGION] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:24:? A[ADDED_TO_REGION, RETURN, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:28:0x007b */
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
public boolean onTouchEvent(androidx.coordinatorlayout.widget.CoordinatorLayout r12, V r13, android.view.MotionEvent r14) {
|
||||
/*
|
||||
r11 = this;
|
||||
int r0 = r14.getActionMasked()
|
||||
r1 = -1
|
||||
r2 = 1
|
||||
r3 = 0
|
||||
if (r0 == r2) goto L4e
|
||||
r4 = 2
|
||||
if (r0 == r4) goto L2d
|
||||
r12 = 3
|
||||
if (r0 == r12) goto L72
|
||||
r12 = 6
|
||||
if (r0 == r12) goto L13
|
||||
goto L4c
|
||||
L13:
|
||||
int r12 = r14.getActionIndex()
|
||||
if (r12 != 0) goto L1b
|
||||
r12 = 1
|
||||
goto L1c
|
||||
L1b:
|
||||
r12 = 0
|
||||
L1c:
|
||||
int r13 = r14.getPointerId(r12)
|
||||
r11.activePointerId = r13
|
||||
float r12 = r14.getY(r12)
|
||||
r13 = 1056964608(0x3f000000, float:0.5)
|
||||
float r12 = r12 + r13
|
||||
int r12 = (int) r12
|
||||
r11.lastMotionY = r12
|
||||
goto L4c
|
||||
L2d:
|
||||
int r0 = r11.activePointerId
|
||||
int r0 = r14.findPointerIndex(r0)
|
||||
if (r0 != r1) goto L36
|
||||
return r3
|
||||
L36:
|
||||
float r0 = r14.getY(r0)
|
||||
int r0 = (int) r0
|
||||
int r1 = r11.lastMotionY
|
||||
int r7 = r1 - r0
|
||||
r11.lastMotionY = r0
|
||||
int r8 = r11.getMaxDragOffset(r13)
|
||||
r9 = 0
|
||||
r4 = r11
|
||||
r5 = r12
|
||||
r6 = r13
|
||||
r4.scroll(r5, r6, r7, r8, r9)
|
||||
L4c:
|
||||
r12 = 0
|
||||
goto L81
|
||||
L4e:
|
||||
android.view.VelocityTracker r0 = r11.velocityTracker
|
||||
if (r0 == 0) goto L72
|
||||
r0.addMovement(r14)
|
||||
android.view.VelocityTracker r0 = r11.velocityTracker
|
||||
r4 = 1000(0x3e8, float:1.401E-42)
|
||||
r0.computeCurrentVelocity(r4)
|
||||
android.view.VelocityTracker r0 = r11.velocityTracker
|
||||
int r4 = r11.activePointerId
|
||||
float r10 = r0.getYVelocity(r4)
|
||||
int r0 = r11.getScrollRangeForDragFling(r13)
|
||||
int r8 = -r0
|
||||
r9 = 0
|
||||
r5 = r11
|
||||
r6 = r12
|
||||
r7 = r13
|
||||
r5.fling(r6, r7, r8, r9, r10)
|
||||
r12 = 1
|
||||
goto L73
|
||||
L72:
|
||||
r12 = 0
|
||||
L73:
|
||||
r11.isBeingDragged = r3
|
||||
r11.activePointerId = r1
|
||||
android.view.VelocityTracker r13 = r11.velocityTracker
|
||||
if (r13 == 0) goto L81
|
||||
r13.recycle()
|
||||
r13 = 0
|
||||
r11.velocityTracker = r13
|
||||
L81:
|
||||
android.view.VelocityTracker r13 = r11.velocityTracker
|
||||
if (r13 == 0) goto L88
|
||||
r13.addMovement(r14)
|
||||
L88:
|
||||
boolean r13 = r11.isBeingDragged
|
||||
if (r13 != 0) goto L90
|
||||
if (r12 == 0) goto L8f
|
||||
goto L90
|
||||
L8f:
|
||||
r2 = 0
|
||||
L90:
|
||||
return r2
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.appbar.HeaderBehavior.onTouchEvent(androidx.coordinatorlayout.widget.CoordinatorLayout, android.view.View, android.view.MotionEvent):boolean");
|
||||
}
|
||||
|
||||
int setHeaderTopBottomOffset(CoordinatorLayout coordinatorLayout, V v, int i) {
|
||||
return setHeaderTopBottomOffset(coordinatorLayout, v, i, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
int setHeaderTopBottomOffset(CoordinatorLayout coordinatorLayout, V v, int i, int i2, int i3) {
|
||||
int clamp;
|
||||
int topAndBottomOffset = getTopAndBottomOffset();
|
||||
if (i2 == 0 || topAndBottomOffset < i2 || topAndBottomOffset > i3 || topAndBottomOffset == (clamp = MathUtils.clamp(i, i2, i3))) {
|
||||
return 0;
|
||||
}
|
||||
setTopAndBottomOffset(clamp);
|
||||
return topAndBottomOffset - clamp;
|
||||
}
|
||||
|
||||
int getTopBottomOffsetForScrollingSibling() {
|
||||
return getTopAndBottomOffset();
|
||||
}
|
||||
|
||||
final int scroll(CoordinatorLayout coordinatorLayout, V v, int i, int i2, int i3) {
|
||||
return setHeaderTopBottomOffset(coordinatorLayout, v, getTopBottomOffsetForScrollingSibling() - i, i2, i3);
|
||||
}
|
||||
|
||||
final boolean fling(CoordinatorLayout coordinatorLayout, V v, int i, int i2, float f) {
|
||||
Runnable runnable = this.flingRunnable;
|
||||
if (runnable != null) {
|
||||
v.removeCallbacks(runnable);
|
||||
this.flingRunnable = null;
|
||||
}
|
||||
if (this.scroller == null) {
|
||||
this.scroller = new OverScroller(v.getContext());
|
||||
}
|
||||
this.scroller.fling(0, getTopAndBottomOffset(), 0, Math.round(f), 0, 0, i, i2);
|
||||
if (this.scroller.computeScrollOffset()) {
|
||||
FlingRunnable flingRunnable = new FlingRunnable(coordinatorLayout, v);
|
||||
this.flingRunnable = flingRunnable;
|
||||
ViewCompat.postOnAnimation(v, flingRunnable);
|
||||
return true;
|
||||
}
|
||||
onFlingFinished(coordinatorLayout, v);
|
||||
return false;
|
||||
}
|
||||
|
||||
int getMaxDragOffset(V v) {
|
||||
return -v.getHeight();
|
||||
}
|
||||
|
||||
int getScrollRangeForDragFling(V v) {
|
||||
return v.getHeight();
|
||||
}
|
||||
|
||||
private void ensureVelocityTracker() {
|
||||
if (this.velocityTracker == null) {
|
||||
this.velocityTracker = VelocityTracker.obtain();
|
||||
}
|
||||
}
|
||||
|
||||
private class FlingRunnable implements Runnable {
|
||||
private final V layout;
|
||||
private final CoordinatorLayout parent;
|
||||
|
||||
FlingRunnable(CoordinatorLayout coordinatorLayout, V v) {
|
||||
this.parent = coordinatorLayout;
|
||||
this.layout = v;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (this.layout == null || HeaderBehavior.this.scroller == null) {
|
||||
return;
|
||||
}
|
||||
if (HeaderBehavior.this.scroller.computeScrollOffset()) {
|
||||
HeaderBehavior headerBehavior = HeaderBehavior.this;
|
||||
headerBehavior.setHeaderTopBottomOffset(this.parent, this.layout, headerBehavior.scroller.getCurrY());
|
||||
ViewCompat.postOnAnimation(this.layout, this);
|
||||
return;
|
||||
}
|
||||
HeaderBehavior.this.onFlingFinished(this.parent, this.layout);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.math.MathUtils;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class HeaderScrollingViewBehavior extends ViewOffsetBehavior<View> {
|
||||
private int overlayTop;
|
||||
final Rect tempRect1;
|
||||
final Rect tempRect2;
|
||||
private int verticalLayoutGap;
|
||||
|
||||
private static int resolveGravity(int i) {
|
||||
if (i == 0) {
|
||||
return 8388659;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
abstract View findFirstDependency(List<View> list);
|
||||
|
||||
float getOverlapRatioForOffset(View view) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public final int getOverlayTop() {
|
||||
return this.overlayTop;
|
||||
}
|
||||
|
||||
final int getVerticalLayoutGap() {
|
||||
return this.verticalLayoutGap;
|
||||
}
|
||||
|
||||
public final void setOverlayTop(int i) {
|
||||
this.overlayTop = i;
|
||||
}
|
||||
|
||||
protected boolean shouldHeaderOverlapScrollingChild() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public HeaderScrollingViewBehavior() {
|
||||
this.tempRect1 = new Rect();
|
||||
this.tempRect2 = new Rect();
|
||||
this.verticalLayoutGap = 0;
|
||||
}
|
||||
|
||||
public HeaderScrollingViewBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.tempRect1 = new Rect();
|
||||
this.tempRect2 = new Rect();
|
||||
this.verticalLayoutGap = 0;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onMeasureChild(CoordinatorLayout coordinatorLayout, View view, int i, int i2, int i3, int i4) {
|
||||
View findFirstDependency;
|
||||
WindowInsetsCompat lastWindowInsets;
|
||||
int i5 = view.getLayoutParams().height;
|
||||
if ((i5 != -1 && i5 != -2) || (findFirstDependency = findFirstDependency(coordinatorLayout.getDependencies(view))) == null) {
|
||||
return false;
|
||||
}
|
||||
int size = View.MeasureSpec.getSize(i3);
|
||||
if (size > 0) {
|
||||
if (ViewCompat.getFitsSystemWindows(findFirstDependency) && (lastWindowInsets = coordinatorLayout.getLastWindowInsets()) != null) {
|
||||
size += lastWindowInsets.getSystemWindowInsetTop() + lastWindowInsets.getSystemWindowInsetBottom();
|
||||
}
|
||||
} else {
|
||||
size = coordinatorLayout.getHeight();
|
||||
}
|
||||
int scrollRange = size + getScrollRange(findFirstDependency);
|
||||
int measuredHeight = findFirstDependency.getMeasuredHeight();
|
||||
if (shouldHeaderOverlapScrollingChild()) {
|
||||
view.setTranslationY(-measuredHeight);
|
||||
} else {
|
||||
view.setTranslationY(0.0f);
|
||||
scrollRange -= measuredHeight;
|
||||
}
|
||||
coordinatorLayout.onMeasureChild(view, i, i2, View.MeasureSpec.makeMeasureSpec(scrollRange, i5 == -1 ? BasicMeasure.EXACTLY : Integer.MIN_VALUE), i4);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.appbar.ViewOffsetBehavior
|
||||
protected void layoutChild(CoordinatorLayout coordinatorLayout, View view, int i) {
|
||||
View findFirstDependency = findFirstDependency(coordinatorLayout.getDependencies(view));
|
||||
if (findFirstDependency != null) {
|
||||
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
|
||||
Rect rect = this.tempRect1;
|
||||
rect.set(coordinatorLayout.getPaddingLeft() + layoutParams.leftMargin, findFirstDependency.getBottom() + layoutParams.topMargin, (coordinatorLayout.getWidth() - coordinatorLayout.getPaddingRight()) - layoutParams.rightMargin, ((coordinatorLayout.getHeight() + findFirstDependency.getBottom()) - coordinatorLayout.getPaddingBottom()) - layoutParams.bottomMargin);
|
||||
WindowInsetsCompat lastWindowInsets = coordinatorLayout.getLastWindowInsets();
|
||||
if (lastWindowInsets != null && ViewCompat.getFitsSystemWindows(coordinatorLayout) && !ViewCompat.getFitsSystemWindows(view)) {
|
||||
rect.left += lastWindowInsets.getSystemWindowInsetLeft();
|
||||
rect.right -= lastWindowInsets.getSystemWindowInsetRight();
|
||||
}
|
||||
Rect rect2 = this.tempRect2;
|
||||
GravityCompat.apply(resolveGravity(layoutParams.gravity), view.getMeasuredWidth(), view.getMeasuredHeight(), rect, rect2, i);
|
||||
int overlapPixelsForOffset = getOverlapPixelsForOffset(findFirstDependency);
|
||||
view.layout(rect2.left, rect2.top - overlapPixelsForOffset, rect2.right, rect2.bottom - overlapPixelsForOffset);
|
||||
this.verticalLayoutGap = rect2.top - findFirstDependency.getBottom();
|
||||
return;
|
||||
}
|
||||
super.layoutChild(coordinatorLayout, view, i);
|
||||
this.verticalLayoutGap = 0;
|
||||
}
|
||||
|
||||
final int getOverlapPixelsForOffset(View view) {
|
||||
if (this.overlayTop == 0) {
|
||||
return 0;
|
||||
}
|
||||
float overlapRatioForOffset = getOverlapRatioForOffset(view);
|
||||
int i = this.overlayTop;
|
||||
return MathUtils.clamp((int) (overlapRatioForOffset * i), 0, i);
|
||||
}
|
||||
|
||||
int getScrollRange(View view) {
|
||||
return view.getMeasuredHeight();
|
||||
}
|
||||
}
|
@ -0,0 +1,292 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Pair;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.view.menu.MenuBuilder;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.drawable.DrawableUtils;
|
||||
import com.google.android.material.internal.ToolbarUtils;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
import com.google.android.material.shape.MaterialShapeUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MaterialToolbar extends Toolbar {
|
||||
private static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_Toolbar;
|
||||
private static final ImageView.ScaleType[] LOGO_SCALE_TYPE_ARRAY = {ImageView.ScaleType.MATRIX, ImageView.ScaleType.FIT_XY, ImageView.ScaleType.FIT_START, ImageView.ScaleType.FIT_CENTER, ImageView.ScaleType.FIT_END, ImageView.ScaleType.CENTER, ImageView.ScaleType.CENTER_CROP, ImageView.ScaleType.CENTER_INSIDE};
|
||||
private Boolean logoAdjustViewBounds;
|
||||
private ImageView.ScaleType logoScaleType;
|
||||
private Integer navigationIconTint;
|
||||
private boolean subtitleCentered;
|
||||
private boolean titleCentered;
|
||||
|
||||
public ImageView.ScaleType getLogoScaleType() {
|
||||
return this.logoScaleType;
|
||||
}
|
||||
|
||||
public Integer getNavigationIconTint() {
|
||||
return this.navigationIconTint;
|
||||
}
|
||||
|
||||
public boolean isSubtitleCentered() {
|
||||
return this.subtitleCentered;
|
||||
}
|
||||
|
||||
public boolean isTitleCentered() {
|
||||
return this.titleCentered;
|
||||
}
|
||||
|
||||
public MaterialToolbar(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public MaterialToolbar(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.toolbarStyle);
|
||||
}
|
||||
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
public MaterialToolbar(android.content.Context r8, android.util.AttributeSet r9, int r10) {
|
||||
/*
|
||||
r7 = this;
|
||||
int r4 = com.google.android.material.appbar.MaterialToolbar.DEF_STYLE_RES
|
||||
android.content.Context r8 = com.google.android.material.theme.overlay.MaterialThemeOverlay.wrap(r8, r9, r10, r4)
|
||||
r7.<init>(r8, r9, r10)
|
||||
android.content.Context r8 = r7.getContext()
|
||||
int[] r2 = com.google.android.material.R.styleable.MaterialToolbar
|
||||
r6 = 0
|
||||
int[] r5 = new int[r6]
|
||||
r0 = r8
|
||||
r1 = r9
|
||||
r3 = r10
|
||||
android.content.res.TypedArray r9 = com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(r0, r1, r2, r3, r4, r5)
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_navigationIconTint
|
||||
boolean r10 = r9.hasValue(r10)
|
||||
r0 = -1
|
||||
if (r10 == 0) goto L2b
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_navigationIconTint
|
||||
int r10 = r9.getColor(r10, r0)
|
||||
r7.setNavigationIconTint(r10)
|
||||
L2b:
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_titleCentered
|
||||
boolean r10 = r9.getBoolean(r10, r6)
|
||||
r7.titleCentered = r10
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_subtitleCentered
|
||||
boolean r10 = r9.getBoolean(r10, r6)
|
||||
r7.subtitleCentered = r10
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_logoScaleType
|
||||
int r10 = r9.getInt(r10, r0)
|
||||
if (r10 < 0) goto L4c
|
||||
android.widget.ImageView$ScaleType[] r0 = com.google.android.material.appbar.MaterialToolbar.LOGO_SCALE_TYPE_ARRAY
|
||||
int r1 = r0.length
|
||||
if (r10 >= r1) goto L4c
|
||||
r10 = r0[r10]
|
||||
r7.logoScaleType = r10
|
||||
L4c:
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_logoAdjustViewBounds
|
||||
boolean r10 = r9.hasValue(r10)
|
||||
if (r10 == 0) goto L60
|
||||
int r10 = com.google.android.material.R.styleable.MaterialToolbar_logoAdjustViewBounds
|
||||
boolean r10 = r9.getBoolean(r10, r6)
|
||||
java.lang.Boolean r10 = java.lang.Boolean.valueOf(r10)
|
||||
r7.logoAdjustViewBounds = r10
|
||||
L60:
|
||||
r9.recycle()
|
||||
r7.initBackground(r8)
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.appbar.MaterialToolbar.<init>(android.content.Context, android.util.AttributeSet, int):void");
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar
|
||||
public void inflateMenu(int i) {
|
||||
Menu menu = getMenu();
|
||||
boolean z = menu instanceof MenuBuilder;
|
||||
if (z) {
|
||||
((MenuBuilder) menu).stopDispatchingItemsChanged();
|
||||
}
|
||||
super.inflateMenu(i);
|
||||
if (z) {
|
||||
((MenuBuilder) menu).startDispatchingItemsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar, android.view.ViewGroup, android.view.View
|
||||
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
||||
super.onLayout(z, i, i2, i3, i4);
|
||||
maybeCenterTitleViews();
|
||||
updateLogoImageView();
|
||||
}
|
||||
|
||||
private void maybeCenterTitleViews() {
|
||||
if (this.titleCentered || this.subtitleCentered) {
|
||||
TextView titleTextView = ToolbarUtils.getTitleTextView(this);
|
||||
TextView subtitleTextView = ToolbarUtils.getSubtitleTextView(this);
|
||||
if (titleTextView == null && subtitleTextView == null) {
|
||||
return;
|
||||
}
|
||||
Pair<Integer, Integer> calculateTitleBoundLimits = calculateTitleBoundLimits(titleTextView, subtitleTextView);
|
||||
if (this.titleCentered && titleTextView != null) {
|
||||
layoutTitleCenteredHorizontally(titleTextView, calculateTitleBoundLimits);
|
||||
}
|
||||
if (!this.subtitleCentered || subtitleTextView == null) {
|
||||
return;
|
||||
}
|
||||
layoutTitleCenteredHorizontally(subtitleTextView, calculateTitleBoundLimits);
|
||||
}
|
||||
}
|
||||
|
||||
private Pair<Integer, Integer> calculateTitleBoundLimits(TextView textView, TextView textView2) {
|
||||
int measuredWidth = getMeasuredWidth();
|
||||
int i = measuredWidth / 2;
|
||||
int paddingLeft = getPaddingLeft();
|
||||
int paddingRight = measuredWidth - getPaddingRight();
|
||||
for (int i2 = 0; i2 < getChildCount(); i2++) {
|
||||
View childAt = getChildAt(i2);
|
||||
if (childAt.getVisibility() != 8 && childAt != textView && childAt != textView2) {
|
||||
if (childAt.getRight() < i && childAt.getRight() > paddingLeft) {
|
||||
paddingLeft = childAt.getRight();
|
||||
}
|
||||
if (childAt.getLeft() > i && childAt.getLeft() < paddingRight) {
|
||||
paddingRight = childAt.getLeft();
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Pair<>(Integer.valueOf(paddingLeft), Integer.valueOf(paddingRight));
|
||||
}
|
||||
|
||||
private void layoutTitleCenteredHorizontally(View view, Pair<Integer, Integer> pair) {
|
||||
int measuredWidth = getMeasuredWidth();
|
||||
int measuredWidth2 = view.getMeasuredWidth();
|
||||
int i = (measuredWidth / 2) - (measuredWidth2 / 2);
|
||||
int i2 = measuredWidth2 + i;
|
||||
int max = Math.max(Math.max(((Integer) pair.first).intValue() - i, 0), Math.max(i2 - ((Integer) pair.second).intValue(), 0));
|
||||
if (max > 0) {
|
||||
i += max;
|
||||
i2 -= max;
|
||||
view.measure(View.MeasureSpec.makeMeasureSpec(i2 - i, BasicMeasure.EXACTLY), view.getMeasuredHeightAndState());
|
||||
}
|
||||
view.layout(i, view.getTop(), i2, view.getBottom());
|
||||
}
|
||||
|
||||
private void updateLogoImageView() {
|
||||
ImageView logoImageView = ToolbarUtils.getLogoImageView(this);
|
||||
if (logoImageView != null) {
|
||||
Boolean bool = this.logoAdjustViewBounds;
|
||||
if (bool != null) {
|
||||
logoImageView.setAdjustViewBounds(bool.booleanValue());
|
||||
}
|
||||
ImageView.ScaleType scaleType = this.logoScaleType;
|
||||
if (scaleType != null) {
|
||||
logoImageView.setScaleType(scaleType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setLogoScaleType(ImageView.ScaleType scaleType) {
|
||||
if (this.logoScaleType != scaleType) {
|
||||
this.logoScaleType = scaleType;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLogoAdjustViewBounds() {
|
||||
Boolean bool = this.logoAdjustViewBounds;
|
||||
return bool != null && bool.booleanValue();
|
||||
}
|
||||
|
||||
public void setLogoAdjustViewBounds(boolean z) {
|
||||
Boolean bool = this.logoAdjustViewBounds;
|
||||
if (bool == null || bool.booleanValue() != z) {
|
||||
this.logoAdjustViewBounds = Boolean.valueOf(z);
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar, android.view.ViewGroup, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
MaterialShapeUtils.setParentAbsoluteElevation(this);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void setElevation(float f) {
|
||||
super.setElevation(f);
|
||||
MaterialShapeUtils.setElevation(this, f);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.Toolbar
|
||||
public void setNavigationIcon(Drawable drawable) {
|
||||
super.setNavigationIcon(maybeTintNavigationIcon(drawable));
|
||||
}
|
||||
|
||||
public void setNavigationIconTint(int i) {
|
||||
this.navigationIconTint = Integer.valueOf(i);
|
||||
Drawable navigationIcon = getNavigationIcon();
|
||||
if (navigationIcon != null) {
|
||||
setNavigationIcon(navigationIcon);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearNavigationIconTint() {
|
||||
this.navigationIconTint = null;
|
||||
Drawable navigationIcon = getNavigationIcon();
|
||||
if (navigationIcon != null) {
|
||||
DrawableCompat.setTintList(DrawableCompat.wrap(navigationIcon.mutate()), null);
|
||||
setNavigationIcon(navigationIcon);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTitleCentered(boolean z) {
|
||||
if (this.titleCentered != z) {
|
||||
this.titleCentered = z;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSubtitleCentered(boolean z) {
|
||||
if (this.subtitleCentered != z) {
|
||||
this.subtitleCentered = z;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private void initBackground(Context context) {
|
||||
ColorStateList colorStateListOrNull;
|
||||
Drawable background = getBackground();
|
||||
if (background == null) {
|
||||
colorStateListOrNull = ColorStateList.valueOf(0);
|
||||
} else {
|
||||
colorStateListOrNull = DrawableUtils.getColorStateListOrNull(background);
|
||||
}
|
||||
if (colorStateListOrNull != null) {
|
||||
MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable();
|
||||
materialShapeDrawable.setFillColor(colorStateListOrNull);
|
||||
materialShapeDrawable.initializeElevationOverlay(context);
|
||||
materialShapeDrawable.setElevation(ViewCompat.getElevation(this));
|
||||
ViewCompat.setBackground(this, materialShapeDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
private Drawable maybeTintNavigationIcon(Drawable drawable) {
|
||||
if (drawable == null || this.navigationIconTint == null) {
|
||||
return drawable;
|
||||
}
|
||||
Drawable wrap = DrawableCompat.wrap(drawable.mutate());
|
||||
DrawableCompat.setTint(wrap, this.navigationIconTint.intValue());
|
||||
return wrap;
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ViewOffsetBehavior<V extends View> extends CoordinatorLayout.Behavior<V> {
|
||||
private int tempLeftRightOffset;
|
||||
private int tempTopBottomOffset;
|
||||
private ViewOffsetHelper viewOffsetHelper;
|
||||
|
||||
public ViewOffsetBehavior() {
|
||||
this.tempTopBottomOffset = 0;
|
||||
this.tempLeftRightOffset = 0;
|
||||
}
|
||||
|
||||
public ViewOffsetBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.tempTopBottomOffset = 0;
|
||||
this.tempLeftRightOffset = 0;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onLayoutChild(CoordinatorLayout coordinatorLayout, V v, int i) {
|
||||
layoutChild(coordinatorLayout, v, i);
|
||||
if (this.viewOffsetHelper == null) {
|
||||
this.viewOffsetHelper = new ViewOffsetHelper(v);
|
||||
}
|
||||
this.viewOffsetHelper.onViewLayout();
|
||||
this.viewOffsetHelper.applyOffsets();
|
||||
int i2 = this.tempTopBottomOffset;
|
||||
if (i2 != 0) {
|
||||
this.viewOffsetHelper.setTopAndBottomOffset(i2);
|
||||
this.tempTopBottomOffset = 0;
|
||||
}
|
||||
int i3 = this.tempLeftRightOffset;
|
||||
if (i3 == 0) {
|
||||
return true;
|
||||
}
|
||||
this.viewOffsetHelper.setLeftAndRightOffset(i3);
|
||||
this.tempLeftRightOffset = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void layoutChild(CoordinatorLayout coordinatorLayout, V v, int i) {
|
||||
coordinatorLayout.onLayoutChild(v, i);
|
||||
}
|
||||
|
||||
public boolean setTopAndBottomOffset(int i) {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
if (viewOffsetHelper != null) {
|
||||
return viewOffsetHelper.setTopAndBottomOffset(i);
|
||||
}
|
||||
this.tempTopBottomOffset = i;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setLeftAndRightOffset(int i) {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
if (viewOffsetHelper != null) {
|
||||
return viewOffsetHelper.setLeftAndRightOffset(i);
|
||||
}
|
||||
this.tempLeftRightOffset = i;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getTopAndBottomOffset() {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
if (viewOffsetHelper != null) {
|
||||
return viewOffsetHelper.getTopAndBottomOffset();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getLeftAndRightOffset() {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
if (viewOffsetHelper != null) {
|
||||
return viewOffsetHelper.getLeftAndRightOffset();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setVerticalOffsetEnabled(boolean z) {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
if (viewOffsetHelper != null) {
|
||||
viewOffsetHelper.setVerticalOffsetEnabled(z);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVerticalOffsetEnabled() {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
return viewOffsetHelper != null && viewOffsetHelper.isVerticalOffsetEnabled();
|
||||
}
|
||||
|
||||
public void setHorizontalOffsetEnabled(boolean z) {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
if (viewOffsetHelper != null) {
|
||||
viewOffsetHelper.setHorizontalOffsetEnabled(z);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHorizontalOffsetEnabled() {
|
||||
ViewOffsetHelper viewOffsetHelper = this.viewOffsetHelper;
|
||||
return viewOffsetHelper != null && viewOffsetHelper.isHorizontalOffsetEnabled();
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ViewOffsetHelper {
|
||||
private int layoutLeft;
|
||||
private int layoutTop;
|
||||
private int offsetLeft;
|
||||
private int offsetTop;
|
||||
private final View view;
|
||||
private boolean verticalOffsetEnabled = true;
|
||||
private boolean horizontalOffsetEnabled = true;
|
||||
|
||||
public int getLayoutLeft() {
|
||||
return this.layoutLeft;
|
||||
}
|
||||
|
||||
public int getLayoutTop() {
|
||||
return this.layoutTop;
|
||||
}
|
||||
|
||||
public int getLeftAndRightOffset() {
|
||||
return this.offsetLeft;
|
||||
}
|
||||
|
||||
public int getTopAndBottomOffset() {
|
||||
return this.offsetTop;
|
||||
}
|
||||
|
||||
public boolean isHorizontalOffsetEnabled() {
|
||||
return this.horizontalOffsetEnabled;
|
||||
}
|
||||
|
||||
public boolean isVerticalOffsetEnabled() {
|
||||
return this.verticalOffsetEnabled;
|
||||
}
|
||||
|
||||
public void setHorizontalOffsetEnabled(boolean z) {
|
||||
this.horizontalOffsetEnabled = z;
|
||||
}
|
||||
|
||||
public void setVerticalOffsetEnabled(boolean z) {
|
||||
this.verticalOffsetEnabled = z;
|
||||
}
|
||||
|
||||
public ViewOffsetHelper(View view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
void onViewLayout() {
|
||||
this.layoutTop = this.view.getTop();
|
||||
this.layoutLeft = this.view.getLeft();
|
||||
}
|
||||
|
||||
void applyOffsets() {
|
||||
View view = this.view;
|
||||
ViewCompat.offsetTopAndBottom(view, this.offsetTop - (view.getTop() - this.layoutTop));
|
||||
View view2 = this.view;
|
||||
ViewCompat.offsetLeftAndRight(view2, this.offsetLeft - (view2.getLeft() - this.layoutLeft));
|
||||
}
|
||||
|
||||
public boolean setTopAndBottomOffset(int i) {
|
||||
if (!this.verticalOffsetEnabled || this.offsetTop == i) {
|
||||
return false;
|
||||
}
|
||||
this.offsetTop = i;
|
||||
applyOffsets();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setLeftAndRightOffset(int i) {
|
||||
if (!this.horizontalOffsetEnabled || this.offsetLeft == i) {
|
||||
return false;
|
||||
}
|
||||
this.offsetLeft = i;
|
||||
applyOffsets();
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.google.android.material.appbar;
|
||||
|
||||
import android.R;
|
||||
import android.animation.AnimatorInflater;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.StateListAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ViewUtilsLollipop {
|
||||
private static final int[] STATE_LIST_ANIM_ATTRS = {R.attr.stateListAnimator};
|
||||
|
||||
ViewUtilsLollipop() {
|
||||
}
|
||||
|
||||
static void setBoundsViewOutlineProvider(View view) {
|
||||
view.setOutlineProvider(ViewOutlineProvider.BOUNDS);
|
||||
}
|
||||
|
||||
static void setStateListAnimatorFromAttrs(View view, AttributeSet attributeSet, int i, int i2) {
|
||||
Context context = view.getContext();
|
||||
TypedArray obtainStyledAttributes = ThemeEnforcement.obtainStyledAttributes(context, attributeSet, STATE_LIST_ANIM_ATTRS, i, i2, new int[0]);
|
||||
try {
|
||||
if (obtainStyledAttributes.hasValue(0)) {
|
||||
view.setStateListAnimator(AnimatorInflater.loadStateListAnimator(context, obtainStyledAttributes.getResourceId(0, 0)));
|
||||
}
|
||||
} finally {
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
static void setDefaultAppBarLayoutStateListAnimator(View view, float f) {
|
||||
int integer = view.getResources().getInteger(com.google.android.material.R.integer.app_bar_elevation_anim_duration);
|
||||
StateListAnimator stateListAnimator = new StateListAnimator();
|
||||
long j = integer;
|
||||
stateListAnimator.addState(new int[]{R.attr.state_enabled, com.google.android.material.R.attr.state_liftable, -com.google.android.material.R.attr.state_lifted}, ObjectAnimator.ofFloat(view, "elevation", 0.0f).setDuration(j));
|
||||
stateListAnimator.addState(new int[]{R.attr.state_enabled}, ObjectAnimator.ofFloat(view, "elevation", f).setDuration(j));
|
||||
stateListAnimator.addState(new int[0], ObjectAnimator.ofFloat(view, "elevation", 0.0f).setDuration(0L));
|
||||
view.setStateListAnimator(stateListAnimator);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user