144 lines
4.1 KiB
Java
144 lines
4.1 KiB
Java
package com.ubt.jimu.connect.view;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Paint;
|
|
import android.util.AttributeSet;
|
|
import android.view.View;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.R$styleable;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class WaveView extends View {
|
|
private int a;
|
|
private int b;
|
|
private int c;
|
|
private Integer d;
|
|
private boolean e;
|
|
private List<Integer> f;
|
|
private List<Integer> g;
|
|
private Paint h;
|
|
private boolean i;
|
|
|
|
public WaveView(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
private void d() {
|
|
this.h = new Paint();
|
|
this.h.setAntiAlias(true);
|
|
this.f.add(255);
|
|
this.g.add(0);
|
|
}
|
|
|
|
public void a() {
|
|
this.f.add(255);
|
|
this.g.add(0);
|
|
}
|
|
|
|
public void b() {
|
|
this.e = true;
|
|
invalidate();
|
|
}
|
|
|
|
public void c() {
|
|
this.e = false;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void invalidate() {
|
|
if (hasWindowFocus()) {
|
|
super.invalidate();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onDraw(Canvas canvas) {
|
|
this.h.setColor(this.a);
|
|
for (int i = 0; i < this.f.size(); i++) {
|
|
Integer num = this.f.get(i);
|
|
this.h.setAlpha(num.intValue());
|
|
Integer num2 = this.g.get(i);
|
|
if (this.i) {
|
|
this.h.setStyle(Paint.Style.FILL);
|
|
canvas.drawCircle(getWidth() / 2, getHeight() / 2, this.b + num2.intValue(), this.h);
|
|
this.h.setStyle(Paint.Style.STROKE);
|
|
this.h.setStrokeWidth(3.0f);
|
|
canvas.drawCircle(getWidth() / 2, getHeight() / 2, this.b + num2.intValue(), this.h);
|
|
} else {
|
|
this.h.setStyle(Paint.Style.STROKE);
|
|
this.h.setStrokeWidth(3.0f);
|
|
canvas.drawCircle(getWidth() / 2, getHeight() / 2, this.b + num2.intValue(), this.h);
|
|
}
|
|
if (this.d.intValue() == 0) {
|
|
this.d = 600;
|
|
}
|
|
if (num.intValue() > 0 && this.b + num2.intValue() < this.d.intValue()) {
|
|
this.f.set(i, Integer.valueOf((int) ((1.0f - (((this.b + num2.intValue()) * 1.0f) / this.d.intValue())) * 255.0f)));
|
|
this.g.set(i, Integer.valueOf(num2.intValue() + 2));
|
|
} else if (num.intValue() < 0 && this.b + num2.intValue() > this.d.intValue()) {
|
|
this.g.remove(i);
|
|
this.f.remove(i);
|
|
}
|
|
}
|
|
if (this.g.get(r9.size() - 1).intValue() >= this.c) {
|
|
a();
|
|
}
|
|
if (this.e) {
|
|
invalidate();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onWindowFocusChanged(boolean z) {
|
|
super.onWindowFocusChanged(z);
|
|
this.d = Integer.valueOf((getWidth() > getHeight() ? getHeight() : getWidth()) / 2);
|
|
invalidate();
|
|
}
|
|
|
|
public void setColor(int i) {
|
|
this.a = i;
|
|
}
|
|
|
|
public void setFill(boolean z) {
|
|
this.i = z;
|
|
}
|
|
|
|
public void setImageRadius(int i) {
|
|
this.b = i;
|
|
}
|
|
|
|
public void setMaxRadius(int i) {
|
|
this.d = Integer.valueOf(i);
|
|
}
|
|
|
|
public void setWidth(int i) {
|
|
this.c = i;
|
|
}
|
|
|
|
public WaveView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public WaveView(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.a = getResources().getColor(R.color.bg_robot_search_wave);
|
|
this.b = 60;
|
|
this.c = 3;
|
|
this.d = 600;
|
|
this.e = false;
|
|
this.f = new ArrayList();
|
|
this.g = new ArrayList();
|
|
this.i = true;
|
|
d();
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.WaveView, i, 0);
|
|
this.a = obtainStyledAttributes.getColor(0, this.a);
|
|
this.c = obtainStyledAttributes.getInt(2, this.c);
|
|
this.b = obtainStyledAttributes.getInt(1, this.b);
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
}
|