OkHttpDownloader.java
2.91 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
package com.squareup.picasso;
import android.content.Context;
import android.net.Uri;
import com.squareup.okhttp.Cache;
import com.squareup.okhttp.CacheControl;
import com.squareup.okhttp.CacheControl.Builder;
import com.squareup.okhttp.Call;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request.Builder;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import java.io.File;
import java.io.IOException;
import sy;
public class OkHttpDownloader
implements Downloader
{
private final OkHttpClient a;
public OkHttpDownloader(Context paramContext)
{
this(sy.b(paramContext));
}
public OkHttpDownloader(Context paramContext, long paramLong)
{
this(sy.b(paramContext), paramLong);
}
public OkHttpDownloader(OkHttpClient paramOkHttpClient)
{
this.a = paramOkHttpClient;
}
public OkHttpDownloader(File paramFile)
{
this(paramFile, sy.a(paramFile));
}
public OkHttpDownloader(File paramFile, long paramLong)
{
this(localOkHttpClient);
try
{
this.a.setCache(new Cache(paramFile, paramLong));
return;
}
catch (IOException paramFile) {}
}
protected final OkHttpClient getClient()
{
return this.a;
}
public Downloader.Response load(Uri paramUri, int paramInt)
throws IOException
{
Object localObject = null;
if (paramInt != 0) {
if (!NetworkPolicy.isOfflineOnly(paramInt)) {
break label116;
}
}
for (localObject = CacheControl.FORCE_CACHE;; localObject = ((CacheControl.Builder)localObject).build())
{
paramUri = new Request.Builder().url(paramUri.toString());
if (localObject != null) {
paramUri.cacheControl((CacheControl)localObject);
}
paramUri = this.a.newCall(paramUri.build()).execute();
int i = paramUri.code();
if (i < 300) {
break;
}
paramUri.body().close();
throw new Downloader.ResponseException(i + " " + paramUri.message(), paramInt, i);
label116:
localObject = new CacheControl.Builder();
if (!NetworkPolicy.shouldReadFromDiskCache(paramInt)) {
((CacheControl.Builder)localObject).noCache();
}
if (!NetworkPolicy.shouldWriteToDiskCache(paramInt)) {
((CacheControl.Builder)localObject).noStore();
}
}
if (paramUri.cacheResponse() != null) {}
for (boolean bool = true;; bool = false)
{
paramUri = paramUri.body();
return new Downloader.Response(paramUri.byteStream(), bool, paramUri.contentLength());
}
}
public void shutdown()
{
Cache localCache = this.a.getCache();
if (localCache != null) {}
try
{
localCache.close();
return;
}
catch (IOException localIOException) {}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/picasso/OkHttpDownloader.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/