package at.technikum.mti.fancycoverflow; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.LinearGradient; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Shader; import android.os.Build; import android.view.View; import android.view.ViewGroup; /* loaded from: classes.dex */ class FancyCoverFlowItemWrapper extends ViewGroup { private float a; private boolean b; private float c; private int d; private float e; private Paint f; private Bitmap g; private Canvas h; public FancyCoverFlowItemWrapper(Context context) { super(context); this.b = false; b(); } private void b() { this.f = new Paint(); b(1.0f); } private void c() { if (getChildAt(0) != null) { int measuredHeight = getMeasuredHeight(); float f = 1.0f; if (this.b) { float f2 = measuredHeight; f = (((1.0f - this.c) * f2) - this.d) / f2; } this.e = f; float f3 = this.e; int i = (int) (measuredHeight * f3); int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i, Integer.MIN_VALUE); getChildAt(0).measure(View.MeasureSpec.makeMeasureSpec((int) (f3 * getMeasuredWidth()), Integer.MIN_VALUE), makeMeasureSpec); } } void a(boolean z) { if (z != this.b) { this.b = z; if (Build.VERSION.SDK_INT >= 11) { setLayerType(z ? 1 : 2, null); } c(); } } @Override // android.view.ViewGroup, android.view.View @TargetApi(11) protected void dispatchDraw(Canvas canvas) { View childAt = getChildAt(0); if (childAt != null) { if (Build.VERSION.SDK_INT < 11) { childAt.draw(this.h); } else if (childAt.isDirty()) { childAt.draw(this.h); if (this.b) { a(); } } } canvas.drawBitmap(this.g, (getWidth() - childAt.getWidth()) / 2, 0.0f, this.f); } @Override // android.view.ViewGroup, android.view.View @SuppressLint({"DrawAllocation"}) protected void onLayout(boolean z, int i, int i2, int i3, int i4) { if (z) { int measuredWidth = getMeasuredWidth(); int measuredHeight = getMeasuredHeight(); Bitmap bitmap = this.g; if (bitmap == null || bitmap.getWidth() != measuredWidth || this.g.getHeight() != measuredHeight) { this.g = Bitmap.createBitmap(measuredWidth, measuredHeight, Bitmap.Config.ARGB_8888); this.h = new Canvas(this.g); } View childAt = getChildAt(0); int measuredWidth2 = (measuredWidth - childAt.getMeasuredWidth()) / 2; childAt.layout(measuredWidth2, 0, measuredWidth - measuredWidth2, childAt.getMeasuredHeight()); } } @Override // android.view.View protected void onMeasure(int i, int i2) { super.onMeasure(i, i2); c(); if (this.b) { setMeasuredDimension((int) (getMeasuredWidth() * this.e), getMeasuredHeight()); } } public void b(float f) { if (f != this.a) { this.a = f; } } void a(float f) { if (f != this.c) { this.c = f; c(); } } void a(int i) { if (i != this.d) { this.d = i; c(); } } private void a() { int width = this.g.getWidth(); int height = this.g.getHeight(); Matrix matrix = new Matrix(); matrix.postScale(1.0f, -1.0f); float f = height; int i = (int) (this.e * f); int i2 = (height - i) - this.d; this.h.drawBitmap(Bitmap.createBitmap(this.g, 0, i - i2, width, i2, matrix, true), 0.0f, i + this.d, (Paint) null); Paint paint = new Paint(); paint.setShader(new LinearGradient(0.0f, (this.c * f) + this.d, 0.0f, f, 1895825407, 16777215, Shader.TileMode.CLAMP)); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN)); this.h.drawRect(0.0f, f * (1.0f - this.c), width, f, paint); } }