116 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			116 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package com.google.android.material.appbar;
 | |
| 
 | |
| import android.content.Context;
 | |
| import android.graphics.Rect;
 | |
| import android.util.AttributeSet;
 | |
| import android.view.View;
 | |
| import android.view.ViewGroup;
 | |
| 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> {
 | |
|     final Rect d;
 | |
|     final Rect e;
 | |
|     private int f;
 | |
|     private int g;
 | |
| 
 | |
|     public HeaderScrollingViewBehavior() {
 | |
|         this.d = new Rect();
 | |
|         this.e = new Rect();
 | |
|         this.f = 0;
 | |
|     }
 | |
| 
 | |
|     private static int c(int i) {
 | |
|         if (i == 0) {
 | |
|             return 8388659;
 | |
|         }
 | |
|         return i;
 | |
|     }
 | |
| 
 | |
|     abstract View a(List<View> list);
 | |
| 
 | |
|     @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
 | |
|     public boolean a(CoordinatorLayout coordinatorLayout, View view, int i, int i2, int i3, int i4) {
 | |
|         View a;
 | |
|         int i5 = view.getLayoutParams().height;
 | |
|         if ((i5 != -1 && i5 != -2) || (a = a(coordinatorLayout.b(view))) == null) {
 | |
|             return false;
 | |
|         }
 | |
|         if (ViewCompat.h(a) && !ViewCompat.h(view)) {
 | |
|             ViewCompat.a(view, true);
 | |
|             if (ViewCompat.h(view)) {
 | |
|                 view.requestLayout();
 | |
|                 return true;
 | |
|             }
 | |
|         }
 | |
|         int size = View.MeasureSpec.getSize(i3);
 | |
|         if (size == 0) {
 | |
|             size = coordinatorLayout.getHeight();
 | |
|         }
 | |
|         coordinatorLayout.a(view, i, i2, View.MeasureSpec.makeMeasureSpec((size - a.getMeasuredHeight()) + c(a), i5 == -1 ? 1073741824 : Integer.MIN_VALUE), i4);
 | |
|         return true;
 | |
|     }
 | |
| 
 | |
|     abstract float b(View view);
 | |
| 
 | |
|     @Override // com.google.android.material.appbar.ViewOffsetBehavior
 | |
|     protected void b(CoordinatorLayout coordinatorLayout, View view, int i) {
 | |
|         View a = a(coordinatorLayout.b(view));
 | |
|         if (a == null) {
 | |
|             super.b(coordinatorLayout, (CoordinatorLayout) view, i);
 | |
|             this.f = 0;
 | |
|             return;
 | |
|         }
 | |
|         CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
 | |
|         Rect rect = this.d;
 | |
|         rect.set(coordinatorLayout.getPaddingLeft() + ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin, a.getBottom() + ((ViewGroup.MarginLayoutParams) layoutParams).topMargin, (coordinatorLayout.getWidth() - coordinatorLayout.getPaddingRight()) - ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin, ((coordinatorLayout.getHeight() + a.getBottom()) - coordinatorLayout.getPaddingBottom()) - ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin);
 | |
|         WindowInsetsCompat lastWindowInsets = coordinatorLayout.getLastWindowInsets();
 | |
|         if (lastWindowInsets != null && ViewCompat.h(coordinatorLayout) && !ViewCompat.h(view)) {
 | |
|             rect.left += lastWindowInsets.c();
 | |
|             rect.right -= lastWindowInsets.d();
 | |
|         }
 | |
|         Rect rect2 = this.e;
 | |
|         GravityCompat.a(c(layoutParams.c), view.getMeasuredWidth(), view.getMeasuredHeight(), rect, rect2, i);
 | |
|         int a2 = a(a);
 | |
|         view.layout(rect2.left, rect2.top - a2, rect2.right, rect2.bottom - a2);
 | |
|         this.f = rect2.top - a.getBottom();
 | |
|     }
 | |
| 
 | |
|     int c(View view) {
 | |
|         return view.getMeasuredHeight();
 | |
|     }
 | |
| 
 | |
|     final int d() {
 | |
|         return this.f;
 | |
|     }
 | |
| 
 | |
|     public final int c() {
 | |
|         return this.g;
 | |
|     }
 | |
| 
 | |
|     public HeaderScrollingViewBehavior(Context context, AttributeSet attributeSet) {
 | |
|         super(context, attributeSet);
 | |
|         this.d = new Rect();
 | |
|         this.e = new Rect();
 | |
|         this.f = 0;
 | |
|     }
 | |
| 
 | |
|     final int a(View view) {
 | |
|         if (this.g == 0) {
 | |
|             return 0;
 | |
|         }
 | |
|         float b = b(view);
 | |
|         int i = this.g;
 | |
|         return MathUtils.a((int) (b * i), 0, i);
 | |
|     }
 | |
| 
 | |
|     public final void b(int i) {
 | |
|         this.g = i;
 | |
|     }
 | |
| }
 |