Picasso.java
17.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
package com.squareup.picasso;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.net.Uri;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.widget.ImageView;
import android.widget.RemoteViews;
import java.io.File;
import java.lang.ref.ReferenceQueue;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ExecutorService;
import se;
import se.a;
import sf;
import sg;
import sh;
import si;
import sj;
import sk;
import sk.1;
import sk.b;
import sm;
import sq;
import sr;
import st;
import su.c;
import sv;
import sw;
import sy;
public class Picasso
{
public static final Handler a = new Handler(Looper.getMainLooper())
{
public final void handleMessage(Message paramAnonymousMessage)
{
int m;
se localse;
Object localObject2;
switch (paramAnonymousMessage.what)
{
default:
throw new AssertionError("Unknown handler message received: " + paramAnonymousMessage.what);
case 8:
paramAnonymousMessage = (List)paramAnonymousMessage.obj;
m = paramAnonymousMessage.size();
i = 0;
case 3:
while (i < m)
{
Object localObject3 = (sg)paramAnonymousMessage.get(i);
localObject1 = ((sg)localObject3).b;
localse = ((sg)localObject3).k;
localObject2 = ((sg)localObject3).l;
int k;
if ((localObject2 != null) && (!((List)localObject2).isEmpty()))
{
j = 1;
if ((localse == null) && (j == 0)) {
break label258;
}
k = 1;
}
for (;;)
{
label153:
if (k != 0)
{
Uri localUri = ((sg)localObject3).g.uri;
Exception localException = ((sg)localObject3).p;
Bitmap localBitmap = ((sg)localObject3).m;
localObject3 = ((sg)localObject3).o;
if (localse != null) {
((Picasso)localObject1).a(localBitmap, (Picasso.LoadedFrom)localObject3, localse);
}
if (j != 0)
{
k = ((List)localObject2).size();
j = 0;
for (;;)
{
if (j < k)
{
((Picasso)localObject1).a(localBitmap, (Picasso.LoadedFrom)localObject3, (se)((List)localObject2).get(j));
j += 1;
continue;
j = 0;
break;
label258:
k = 0;
break label153;
}
}
}
if ((((Picasso)localObject1).c != null) && (localException != null)) {
((Picasso)localObject1).c.onImageLoadFailed((Picasso)localObject1, localUri, localException);
}
}
}
i += 1;
continue;
paramAnonymousMessage = (se)paramAnonymousMessage.obj;
if (paramAnonymousMessage.a.o) {
sy.a("Main", "canceled", paramAnonymousMessage.b.a(), "target got garbage collected");
}
Picasso.a(paramAnonymousMessage.a, paramAnonymousMessage.c());
}
return;
}
Object localObject1 = (List)paramAnonymousMessage.obj;
int j = ((List)localObject1).size();
int i = 0;
label365:
if (i < j)
{
localse = (se)((List)localObject1).get(i);
localObject2 = localse.a;
paramAnonymousMessage = null;
if (MemoryPolicy.a(localse.e)) {
paramAnonymousMessage = ((Picasso)localObject2).a(localse.i);
}
if (paramAnonymousMessage == null) {
break label477;
}
((Picasso)localObject2).a(paramAnonymousMessage, Picasso.LoadedFrom.MEMORY, localse);
if (((Picasso)localObject2).o) {
sy.a("Main", "completed", localse.b.a(), "from " + Picasso.LoadedFrom.MEMORY);
}
}
for (;;)
{
i += 1;
break label365;
break;
label477:
((Picasso)localObject2).a(localse);
if (((Picasso)localObject2).o) {
sy.a("Main", "resumed", localse.b.a());
}
}
}
};
static volatile Picasso b = null;
final Listener c;
final RequestTransformer d;
public final List<RequestHandler> e;
public final Context f;
final sk g;
final Cache h;
final sw i;
final Map<Object, se> j;
final Map<ImageView, sj> k;
public final ReferenceQueue<Object> l;
final Bitmap.Config m;
public boolean n;
public volatile boolean o;
boolean p;
private final a q;
Picasso(Context paramContext, sk paramsk, Cache paramCache, Listener paramListener, RequestTransformer paramRequestTransformer, List<RequestHandler> paramList, sw paramsw, Bitmap.Config paramConfig, boolean paramBoolean1, boolean paramBoolean2)
{
this.f = paramContext;
this.g = paramsk;
this.h = paramCache;
this.c = paramListener;
this.d = paramRequestTransformer;
this.m = paramConfig;
if (paramList != null) {}
for (int i1 = paramList.size();; i1 = 0)
{
paramCache = new ArrayList(i1 + 7);
paramCache.add(new sv(paramContext));
if (paramList != null) {
paramCache.addAll(paramList);
}
paramCache.add(new sh(paramContext));
paramCache.add(new sq(paramContext));
paramCache.add(new si(paramContext));
paramCache.add(new sf(paramContext));
paramCache.add(new sm(paramContext));
paramCache.add(new sr(paramsk.d, paramsw));
this.e = Collections.unmodifiableList(paramCache);
this.i = paramsw;
this.j = new WeakHashMap();
this.k = new WeakHashMap();
this.n = paramBoolean1;
this.o = paramBoolean2;
this.l = new ReferenceQueue();
this.q = new a(this.l, a);
this.q.start();
return;
}
}
private void a(Object paramObject)
{
sy.b();
se localse = (se)this.j.remove(paramObject);
if (localse != null)
{
localse.b();
sk localsk = this.g;
localsk.i.sendMessage(localsk.i.obtainMessage(2, localse));
}
if ((paramObject instanceof ImageView))
{
paramObject = (ImageView)paramObject;
paramObject = (sj)this.k.remove(paramObject);
if (paramObject != null) {
((sj)paramObject).a();
}
}
}
public static void setSingletonInstance(Picasso paramPicasso)
{
try
{
if (b != null) {
throw new IllegalStateException("Singleton instance already exists.");
}
}
finally {}
b = paramPicasso;
}
public static Picasso with(Context paramContext)
{
if (b == null) {}
try
{
if (b == null) {
b = new Builder(paramContext).build();
}
return b;
}
finally {}
}
final Bitmap a(String paramString)
{
paramString = this.h.get(paramString);
if (paramString != null)
{
this.i.a();
return paramString;
}
this.i.c.sendEmptyMessage(1);
return paramString;
}
final void a(Bitmap paramBitmap, LoadedFrom paramLoadedFrom, se paramse)
{
if (paramse.l) {}
do
{
do
{
return;
if (!paramse.k) {
this.j.remove(paramse.c());
}
if (paramBitmap == null) {
break;
}
if (paramLoadedFrom == null) {
throw new AssertionError("LoadedFrom cannot be null.");
}
paramse.a(paramBitmap, paramLoadedFrom);
} while (!this.o);
sy.a("Main", "completed", paramse.b.a(), "from " + paramLoadedFrom);
return;
paramse.a();
} while (!this.o);
sy.a("Main", "errored", paramse.b.a());
}
final void a(se paramse)
{
Object localObject = paramse.c();
if ((localObject != null) && (this.j.get(localObject) != paramse))
{
a(localObject);
this.j.put(localObject, paramse);
}
b(paramse);
}
public boolean areIndicatorsEnabled()
{
return this.n;
}
final void b(se paramse)
{
sk localsk = this.g;
localsk.i.sendMessage(localsk.i.obtainMessage(1, paramse));
}
public void cancelRequest(ImageView paramImageView)
{
a(paramImageView);
}
public void cancelRequest(RemoteViews paramRemoteViews, int paramInt)
{
a(new su.c(paramRemoteViews, paramInt));
}
public void cancelRequest(Target paramTarget)
{
a(paramTarget);
}
public void cancelTag(Object paramObject)
{
sy.b();
ArrayList localArrayList = new ArrayList(this.j.values());
int i2 = localArrayList.size();
int i1 = 0;
while (i1 < i2)
{
se localse = (se)localArrayList.get(i1);
if (localse.j.equals(paramObject)) {
a(localse.c());
}
i1 += 1;
}
}
public StatsSnapshot getSnapshot()
{
return this.i.b();
}
public void invalidate(Uri paramUri)
{
if (paramUri == null) {
throw new IllegalArgumentException("uri == null");
}
this.h.clearKeyUri(paramUri.toString());
}
public void invalidate(File paramFile)
{
if (paramFile == null) {
throw new IllegalArgumentException("file == null");
}
invalidate(Uri.fromFile(paramFile));
}
public void invalidate(String paramString)
{
if (paramString == null) {
throw new IllegalArgumentException("path == null");
}
invalidate(Uri.parse(paramString));
}
@Deprecated
public boolean isDebugging()
{
return (areIndicatorsEnabled()) && (isLoggingEnabled());
}
public boolean isLoggingEnabled()
{
return this.o;
}
public RequestCreator load(int paramInt)
{
if (paramInt == 0) {
throw new IllegalArgumentException("Resource ID must not be zero.");
}
return new RequestCreator(this, null, paramInt);
}
public RequestCreator load(Uri paramUri)
{
return new RequestCreator(this, paramUri, 0);
}
public RequestCreator load(File paramFile)
{
if (paramFile == null) {
return new RequestCreator(this, null, 0);
}
return load(Uri.fromFile(paramFile));
}
public RequestCreator load(String paramString)
{
if (paramString == null) {
return new RequestCreator(this, null, 0);
}
if (paramString.trim().length() == 0) {
throw new IllegalArgumentException("Path must not be empty.");
}
return load(Uri.parse(paramString));
}
public void pauseTag(Object paramObject)
{
sk localsk = this.g;
localsk.i.sendMessage(localsk.i.obtainMessage(11, paramObject));
}
public void resumeTag(Object paramObject)
{
sk localsk = this.g;
localsk.i.sendMessage(localsk.i.obtainMessage(12, paramObject));
}
@Deprecated
public void setDebugging(boolean paramBoolean)
{
setIndicatorsEnabled(paramBoolean);
}
public void setIndicatorsEnabled(boolean paramBoolean)
{
this.n = paramBoolean;
}
public void setLoggingEnabled(boolean paramBoolean)
{
this.o = paramBoolean;
}
public void shutdown()
{
if (this == b) {
throw new UnsupportedOperationException("Default singleton instance cannot be shutdown.");
}
if (this.p) {
return;
}
this.h.clear();
this.q.interrupt();
this.i.a.quit();
Object localObject = this.g;
if ((((sk)localObject).c instanceof st)) {
((sk)localObject).c.shutdown();
}
((sk)localObject).d.shutdown();
((sk)localObject).a.quit();
a.post(new sk.1((sk)localObject));
localObject = this.k.values().iterator();
while (((Iterator)localObject).hasNext()) {
((sj)((Iterator)localObject).next()).a();
}
this.k.clear();
this.p = true;
}
public static class Builder
{
private final Context a;
private Downloader b;
private ExecutorService c;
private Cache d;
private Picasso.Listener e;
private Picasso.RequestTransformer f;
private List<RequestHandler> g;
private Bitmap.Config h;
private boolean i;
private boolean j;
public Builder(Context paramContext)
{
if (paramContext == null) {
throw new IllegalArgumentException("Context must not be null.");
}
this.a = paramContext.getApplicationContext();
}
public Builder addRequestHandler(RequestHandler paramRequestHandler)
{
if (paramRequestHandler == null) {
throw new IllegalArgumentException("RequestHandler must not be null.");
}
if (this.g == null) {
this.g = new ArrayList();
}
if (this.g.contains(paramRequestHandler)) {
throw new IllegalStateException("RequestHandler already registered.");
}
this.g.add(paramRequestHandler);
return this;
}
public Picasso build()
{
Context localContext = this.a;
if (this.b == null) {
this.b = sy.a(localContext);
}
if (this.d == null) {
this.d = new LruCache(localContext);
}
if (this.c == null) {
this.c = new st();
}
if (this.f == null) {
this.f = Picasso.RequestTransformer.IDENTITY;
}
sw localsw = new sw(this.d);
return new Picasso(localContext, new sk(localContext, this.c, Picasso.a, this.b, this.d, localsw), this.d, this.e, this.f, this.g, localsw, this.h, this.i, this.j);
}
@Deprecated
public Builder debugging(boolean paramBoolean)
{
return indicatorsEnabled(paramBoolean);
}
public Builder defaultBitmapConfig(Bitmap.Config paramConfig)
{
if (paramConfig == null) {
throw new IllegalArgumentException("Bitmap config must not be null.");
}
this.h = paramConfig;
return this;
}
public Builder downloader(Downloader paramDownloader)
{
if (paramDownloader == null) {
throw new IllegalArgumentException("Downloader must not be null.");
}
if (this.b != null) {
throw new IllegalStateException("Downloader already set.");
}
this.b = paramDownloader;
return this;
}
public Builder executor(ExecutorService paramExecutorService)
{
if (paramExecutorService == null) {
throw new IllegalArgumentException("Executor service must not be null.");
}
if (this.c != null) {
throw new IllegalStateException("Executor service already set.");
}
this.c = paramExecutorService;
return this;
}
public Builder indicatorsEnabled(boolean paramBoolean)
{
this.i = paramBoolean;
return this;
}
public Builder listener(Picasso.Listener paramListener)
{
if (paramListener == null) {
throw new IllegalArgumentException("Listener must not be null.");
}
if (this.e != null) {
throw new IllegalStateException("Listener already set.");
}
this.e = paramListener;
return this;
}
public Builder loggingEnabled(boolean paramBoolean)
{
this.j = paramBoolean;
return this;
}
public Builder memoryCache(Cache paramCache)
{
if (paramCache == null) {
throw new IllegalArgumentException("Memory cache must not be null.");
}
if (this.d != null) {
throw new IllegalStateException("Memory cache already set.");
}
this.d = paramCache;
return this;
}
public Builder requestTransformer(Picasso.RequestTransformer paramRequestTransformer)
{
if (paramRequestTransformer == null) {
throw new IllegalArgumentException("Transformer must not be null.");
}
if (this.f != null) {
throw new IllegalStateException("Transformer already set.");
}
this.f = paramRequestTransformer;
return this;
}
}
public static abstract interface Listener
{
public abstract void onImageLoadFailed(Picasso paramPicasso, Uri paramUri, Exception paramException);
}
public static enum LoadedFrom
{
public final int a;
private LoadedFrom(int paramInt)
{
this.a = paramInt;
}
}
public static enum Priority
{
private Priority() {}
}
public static abstract interface RequestTransformer
{
public static final RequestTransformer IDENTITY = new RequestTransformer()
{
public final Request transformRequest(Request paramAnonymousRequest)
{
return paramAnonymousRequest;
}
};
public abstract Request transformRequest(Request paramRequest);
}
static final class a
extends Thread
{
private final ReferenceQueue<Object> a;
private final Handler b;
a(ReferenceQueue<Object> paramReferenceQueue, Handler paramHandler)
{
this.a = paramReferenceQueue;
this.b = paramHandler;
setDaemon(true);
setName("Picasso-refQueue");
}
public final void run()
{
Process.setThreadPriority(10);
try
{
for (;;)
{
se.a locala = (se.a)this.a.remove(1000L);
Message localMessage = this.b.obtainMessage();
if (locala != null)
{
localMessage.what = 3;
localMessage.obj = locala.a;
this.b.sendMessage(localMessage);
}
else
{
localMessage.recycle();
}
}
return;
}
catch (Exception localException)
{
this.b.post(new Runnable()
{
public final void run()
{
throw new RuntimeException(localException);
}
});
return;
}
catch (InterruptedException localInterruptedException) {}
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/picasso/Picasso.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/