jimu-decompiled/sources/com/recyclelib/RefreshHeaderViewCompact.java
2025-05-13 19:24:51 +02:00

206 lines
6.4 KiB
Java

package com.recyclelib;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
/* loaded from: classes.dex */
public class RefreshHeaderViewCompact extends LinearLayout implements OnRefreshListener {
private Context a;
private View b;
private ImageView c;
private TextView d;
private int e;
private int f;
private boolean g;
private boolean h;
private Matrix i;
private float j;
private float k;
private ObjectAnimator l;
private Handler m;
public RefreshHeaderViewCompact(Context context) {
super(context);
this.f = 0;
this.g = false;
this.h = true;
this.m = new Handler();
a(context);
}
private void e() {
Log.i("STATE_DONE", "onLoadingDrawableSet");
Drawable drawable = this.c.getDrawable();
this.j = Math.round(drawable.getIntrinsicWidth() / 2.0f);
this.k = Math.round(drawable.getIntrinsicHeight() / 2.0f);
}
/* JADX INFO: Access modifiers changed from: private */
public void setState(int i) {
if (this.f == i) {
return;
}
if (i == 2) {
a(this.e);
}
if (i != 0) {
if (i != 1) {
if (i == 2) {
if (!this.g) {
this.d.setText(R$string.pull_to_refresh_refreshing_label);
}
this.l.start();
} else if (i == 3) {
Log.i("STATE_DONE", "clear animation");
this.c.clearAnimation();
}
} else if (this.f != 1 && !this.g) {
this.d.setText(R$string.pull_to_refresh_release_label);
}
} else if (!this.g) {
this.d.setText(R$string.pull_to_refresh_pull_label);
}
this.f = i;
}
public void b(float f) {
if (getVisibleHeight() > 0 || f > 0.0f) {
setVisibleHeight(((int) f) + getVisibleHeight());
if (this.f <= 1) {
if (getVisibleHeight() > this.e / 2) {
setState(1);
} else {
setState(0);
}
}
}
}
public boolean c() {
boolean z;
getVisibleHeight();
if (getVisibleHeight() <= (this.e * 2) / 3 || this.f >= 2) {
z = false;
} else {
setState(2);
z = true;
}
int i = this.f;
a(this.f == 2 ? this.e : 0);
return z;
}
public void d() {
Matrix matrix = this.i;
if (matrix != null) {
matrix.reset();
this.c.setImageMatrix(this.i);
}
a(0);
this.m.postDelayed(new Runnable() { // from class: com.recyclelib.RefreshHeaderViewCompact.1
@Override // java.lang.Runnable
public void run() {
RefreshHeaderViewCompact.this.setState(0);
}
}, 500L);
}
public int getState() {
return this.f;
}
public int getVisibleHeight() {
return ((LinearLayout.LayoutParams) this.b.getLayoutParams()).height;
}
public void setVisibleHeight(int i) {
if (i < 0) {
i = 0;
}
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.b.getLayoutParams();
layoutParams.height = i;
this.b.setLayoutParams(layoutParams);
}
public boolean a() {
return this.h;
}
private void a(Context context) {
this.a = context;
LayoutInflater from = LayoutInflater.from(context);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
layoutParams.setMargins(0, 0, 0, 0);
setLayoutParams(layoutParams);
setPadding(0, 0, 0, 0);
this.b = from.inflate(R$layout.refresh_header_view, (ViewGroup) null);
addView(this.b, new LinearLayout.LayoutParams(-1, 0));
setGravity(80);
this.c = (ImageView) this.b.findViewById(R$id.head_progressBar);
this.d = (TextView) this.b.findViewById(R$id.refresh_status_textview);
this.i = new Matrix();
this.c.setImageMatrix(this.i);
e();
this.l = ObjectAnimator.ofFloat(this.c, "rotation", 0.0f, 180.0f, 360.0f);
this.l.setRepeatCount(-1);
this.l.setRepeatMode(1);
this.l.setDuration(1200L);
this.l.setInterpolator(new LinearInterpolator());
measure(-2, -2);
this.e = getMeasuredHeight();
}
public void b() {
setState(3);
this.m.postDelayed(new Runnable() { // from class: com.recyclelib.RefreshHeaderViewCompact.3
@Override // java.lang.Runnable
public void run() {
RefreshHeaderViewCompact.this.d();
}
}, 500L);
}
public void a(boolean z) {
if (this.g != z) {
this.g = z;
this.d.setVisibility(z ? 8 : 0);
}
}
private void a(int i) {
ValueAnimator ofInt = ValueAnimator.ofInt(getVisibleHeight(), i);
ofInt.setDuration(300L).start();
ofInt.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.recyclelib.RefreshHeaderViewCompact.2
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator) {
RefreshHeaderViewCompact.this.setVisibleHeight(((Integer) valueAnimator.getAnimatedValue()).intValue());
}
});
ofInt.start();
}
public void a(float f) {
if (getVisibleHeight() <= 0 || f <= 0.0f) {
return;
}
float visibleHeight = getVisibleHeight();
float abs = Math.abs(visibleHeight / Utils.a(this.a, 46));
float max = this.h ? 90.0f * abs : Math.max(0.0f, Math.min(180.0f, (360.0f * abs) - 180.0f));
Log.i("refreshHeaderView", "delta:" + f + " height:" + visibleHeight + " angle:" + max + " scale:" + abs);
this.i.setRotate(max, this.j, this.k);
this.c.setImageMatrix(this.i);
}
}