262 lines
7.8 KiB
Java
262 lines
7.8 KiB
Java
package at.technikum.mti.fancycoverflow;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.Camera;
|
|
import android.graphics.Matrix;
|
|
import android.os.Build;
|
|
import android.util.AttributeSet;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.animation.Transformation;
|
|
import android.widget.Gallery;
|
|
import android.widget.SpinnerAdapter;
|
|
import at.technikum.mti.fancycoverflow.AutoPlayer;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class FancyCoverFlow extends Gallery {
|
|
private float a;
|
|
private int b;
|
|
private boolean c;
|
|
private float d;
|
|
private Camera e;
|
|
private int f;
|
|
private float g;
|
|
private float h;
|
|
private int i;
|
|
private float j;
|
|
private AutoPlayer.Playable k;
|
|
private AutoPlayer l;
|
|
protected int m;
|
|
|
|
public static class LayoutParams extends Gallery.LayoutParams {
|
|
public LayoutParams(int i, int i2) {
|
|
super(i, i2);
|
|
}
|
|
}
|
|
|
|
public FancyCoverFlow(Context context) {
|
|
super(context);
|
|
this.a = 0.4f;
|
|
this.b = 20;
|
|
this.c = false;
|
|
this.f = 75;
|
|
this.h = 0.5f;
|
|
this.k = new AutoPlayer.Playable(this) { // from class: at.technikum.mti.fancycoverflow.FancyCoverFlow.1
|
|
};
|
|
this.m = 2000;
|
|
b();
|
|
}
|
|
|
|
private void a(AttributeSet attributeSet) {
|
|
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, R$styleable.FancyCoverFlow);
|
|
this.i = obtainStyledAttributes.getInteger(R$styleable.FancyCoverFlow_actionDistance, Integer.MAX_VALUE);
|
|
this.h = obtainStyledAttributes.getFloat(R$styleable.FancyCoverFlow_scaleDownGravity, 1.0f);
|
|
this.f = obtainStyledAttributes.getInteger(R$styleable.FancyCoverFlow_maxRotation, 45);
|
|
this.d = obtainStyledAttributes.getFloat(R$styleable.FancyCoverFlow_unselectedAlpha, 0.3f);
|
|
this.j = obtainStyledAttributes.getFloat(R$styleable.FancyCoverFlow_unselectedSaturation, 0.0f);
|
|
this.g = obtainStyledAttributes.getFloat(R$styleable.FancyCoverFlow_unselectedScale, 0.75f);
|
|
}
|
|
|
|
private void b() {
|
|
this.e = new Camera();
|
|
setSpacing(0);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public boolean dispatchTouchEvent(MotionEvent motionEvent) {
|
|
AutoPlayer autoPlayer;
|
|
int action = motionEvent.getAction();
|
|
if (action == 0) {
|
|
AutoPlayer autoPlayer2 = this.l;
|
|
if (autoPlayer2 != null) {
|
|
autoPlayer2.a();
|
|
}
|
|
} else if ((action == 1 || action == 3) && (autoPlayer = this.l) != null) {
|
|
autoPlayer.b();
|
|
}
|
|
return super.dispatchTouchEvent(motionEvent);
|
|
}
|
|
|
|
public int getActionDistance() {
|
|
return this.i;
|
|
}
|
|
|
|
@Override // android.widget.Gallery, android.view.ViewGroup
|
|
protected boolean getChildStaticTransformation(View view, Transformation transformation) {
|
|
FancyCoverFlowItemWrapper fancyCoverFlowItemWrapper = (FancyCoverFlowItemWrapper) view;
|
|
if (Build.VERSION.SDK_INT >= 16) {
|
|
fancyCoverFlowItemWrapper.invalidate();
|
|
}
|
|
int width = getWidth() / 2;
|
|
int width2 = fancyCoverFlowItemWrapper.getWidth();
|
|
int height = fancyCoverFlowItemWrapper.getHeight();
|
|
int left = fancyCoverFlowItemWrapper.getLeft() + (width2 / 2);
|
|
int i = this.i;
|
|
if (i == Integer.MAX_VALUE) {
|
|
i = (int) ((r0 + width2) / 2.0f);
|
|
}
|
|
float min = Math.min(1.0f, Math.max(-1.0f, (1.0f / i) * (left - width)));
|
|
transformation.clear();
|
|
transformation.setTransformationType(3);
|
|
float f = this.d;
|
|
if (f != 1.0f) {
|
|
transformation.setAlpha(((f - 1.0f) * Math.abs(min)) + 1.0f);
|
|
}
|
|
float f2 = this.j;
|
|
if (f2 != 1.0f) {
|
|
fancyCoverFlowItemWrapper.b(((f2 - 1.0f) * Math.abs(min)) + 1.0f);
|
|
}
|
|
Matrix matrix = transformation.getMatrix();
|
|
if (this.f != 0) {
|
|
this.e.save();
|
|
this.e.rotateY((int) ((-min) * r10));
|
|
this.e.getMatrix(matrix);
|
|
this.e.restore();
|
|
}
|
|
float f3 = this.g;
|
|
if (f3 == 1.0f) {
|
|
return true;
|
|
}
|
|
float abs = ((f3 - 1.0f) * Math.abs(min)) + 1.0f;
|
|
float f4 = width2 / 2.0f;
|
|
float f5 = height * this.h;
|
|
matrix.preTranslate(-f4, -f5);
|
|
matrix.postScale(abs, abs);
|
|
matrix.postTranslate(f4, f5);
|
|
return true;
|
|
}
|
|
|
|
public int getMaxRotation() {
|
|
return this.f;
|
|
}
|
|
|
|
public int getReflectionGap() {
|
|
return this.b;
|
|
}
|
|
|
|
public float getReflectionRatio() {
|
|
return this.a;
|
|
}
|
|
|
|
public float getScaleDownGravity() {
|
|
return this.h;
|
|
}
|
|
|
|
public float getUnselectedAlpha() {
|
|
return this.d;
|
|
}
|
|
|
|
public float getUnselectedSaturation() {
|
|
return this.j;
|
|
}
|
|
|
|
public float getUnselectedScale() {
|
|
return this.g;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onFinishInflate() {
|
|
super.onFinishInflate();
|
|
AutoPlayer autoPlayer = new AutoPlayer(this.k);
|
|
autoPlayer.a(AutoPlayer.PlayRecycleMode.play_back);
|
|
this.l = autoPlayer;
|
|
this.l.a(this.m);
|
|
}
|
|
|
|
public void setActionDistance(int i) {
|
|
this.i = i;
|
|
}
|
|
|
|
public void setMaxRotation(int i) {
|
|
this.f = i;
|
|
}
|
|
|
|
public void setReflectionEnabled(boolean z) {
|
|
this.c = z;
|
|
if (getAdapter() != null) {
|
|
((FancyCoverFlowAdapter) getAdapter()).notifyDataSetChanged();
|
|
}
|
|
}
|
|
|
|
public void setReflectionGap(int i) {
|
|
this.b = i;
|
|
if (getAdapter() != null) {
|
|
((FancyCoverFlowAdapter) getAdapter()).notifyDataSetChanged();
|
|
}
|
|
}
|
|
|
|
public void setReflectionRatio(float f) {
|
|
if (f <= 0.0f || f > 0.5f) {
|
|
throw new IllegalArgumentException("reflectionRatio may only be in the interval (0, 0.5]");
|
|
}
|
|
this.a = f;
|
|
if (getAdapter() != null) {
|
|
((FancyCoverFlowAdapter) getAdapter()).notifyDataSetChanged();
|
|
}
|
|
}
|
|
|
|
public void setScaleDownGravity(float f) {
|
|
this.h = f;
|
|
}
|
|
|
|
public void setTimeInterval(int i) {
|
|
this.l.a(i);
|
|
}
|
|
|
|
@Override // android.widget.Gallery
|
|
public void setUnselectedAlpha(float f) {
|
|
super.setUnselectedAlpha(f);
|
|
this.d = f;
|
|
}
|
|
|
|
public void setUnselectedSaturation(float f) {
|
|
this.j = f;
|
|
}
|
|
|
|
public void setUnselectedScale(float f) {
|
|
this.g = f;
|
|
}
|
|
|
|
@Override // android.widget.AdapterView
|
|
public void setAdapter(SpinnerAdapter spinnerAdapter) {
|
|
if (spinnerAdapter instanceof FancyCoverFlowAdapter) {
|
|
super.setAdapter(spinnerAdapter);
|
|
return;
|
|
}
|
|
throw new ClassCastException(FancyCoverFlow.class.getSimpleName() + " only works in conjunction with a " + FancyCoverFlowAdapter.class.getSimpleName());
|
|
}
|
|
|
|
public boolean a() {
|
|
return this.c;
|
|
}
|
|
|
|
public FancyCoverFlow(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.a = 0.4f;
|
|
this.b = 20;
|
|
this.c = false;
|
|
this.f = 75;
|
|
this.h = 0.5f;
|
|
this.k = new AutoPlayer.Playable(this) { // from class: at.technikum.mti.fancycoverflow.FancyCoverFlow.1
|
|
};
|
|
this.m = 2000;
|
|
b();
|
|
a(attributeSet);
|
|
}
|
|
|
|
public FancyCoverFlow(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.a = 0.4f;
|
|
this.b = 20;
|
|
this.c = false;
|
|
this.f = 75;
|
|
this.h = 0.5f;
|
|
this.k = new AutoPlayer.Playable(this) { // from class: at.technikum.mti.fancycoverflow.FancyCoverFlow.1
|
|
};
|
|
this.m = 2000;
|
|
b();
|
|
a(attributeSet);
|
|
}
|
|
}
|