jimu-decompiled/sources/com/squareup/picasso/Stats.java
2025-05-13 19:24:51 +02:00

132 lines
3.0 KiB
Java

package com.squareup.picasso;
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
/* loaded from: classes.dex */
class Stats {
final HandlerThread a = new HandlerThread("Picasso-Stats", 10);
final Cache b;
final Handler c;
long d;
long e;
long f;
long g;
long h;
long i;
long j;
long k;
int l;
int m;
int n;
private static class StatsHandler extends Handler {
private final Stats a;
public StatsHandler(Looper looper, Stats stats) {
super(looper);
this.a = stats;
}
@Override // android.os.Handler
public void handleMessage(final Message message) {
int i = message.what;
if (i == 0) {
this.a.d();
return;
}
if (i == 1) {
this.a.e();
return;
}
if (i == 2) {
this.a.b(message.arg1);
return;
}
if (i == 3) {
this.a.c(message.arg1);
} else if (i != 4) {
Picasso.p.post(new Runnable(this) { // from class: com.squareup.picasso.Stats.StatsHandler.1
@Override // java.lang.Runnable
public void run() {
throw new AssertionError("Unhandled stats message." + message.what);
}
});
} else {
this.a.a((Long) message.obj);
}
}
}
Stats(Cache cache) {
this.b = cache;
this.a.start();
Utils.a(this.a.getLooper());
this.c = new StatsHandler(this.a.getLooper(), this);
}
void a(Bitmap bitmap) {
a(bitmap, 2);
}
void b(Bitmap bitmap) {
a(bitmap, 3);
}
void c() {
this.c.sendEmptyMessage(1);
}
void d() {
this.d++;
}
void e() {
this.e++;
}
void a(long j) {
Handler handler = this.c;
handler.sendMessage(handler.obtainMessage(4, Long.valueOf(j)));
}
void b() {
this.c.sendEmptyMessage(0);
}
void c(long j) {
this.n++;
this.h += j;
this.k = a(this.m, this.h);
}
void a(Long l) {
this.l++;
this.f += l.longValue();
this.i = a(this.l, this.f);
}
void b(long j) {
this.m++;
this.g += j;
this.j = a(this.m, this.g);
}
StatsSnapshot a() {
return new StatsSnapshot(this.b.a(), this.b.size(), this.d, this.e, this.f, this.g, this.h, this.i, this.j, this.k, this.l, this.m, this.n, System.currentTimeMillis());
}
private void a(Bitmap bitmap, int i) {
int a = Utils.a(bitmap);
Handler handler = this.c;
handler.sendMessage(handler.obtainMessage(i, a, 0));
}
private static long a(int i, long j) {
return j / i;
}
}