hm.java
2.49 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
import android.content.Context;
import android.net.Uri;
import android.support.annotation.VisibleForTesting;
import com.bitstrips.imoji.persistence.MediaCache;
import com.bitstrips.imoji.util.WebUtils;
import com.squareup.okhttp.Call;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Request.Builder;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import com.squareup.picasso.Downloader;
import com.squareup.picasso.Downloader.Response;
import com.squareup.picasso.Downloader.ResponseException;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
public final class hm
implements Downloader
{
private final OkHttpClient a;
private final MediaCache b;
private final Context c;
public hm(MediaCache paramMediaCache, Context paramContext)
{
this(paramMediaCache, new OkHttpClient(), paramContext);
}
@VisibleForTesting
private hm(MediaCache paramMediaCache, OkHttpClient paramOkHttpClient, Context paramContext)
{
paramOkHttpClient.setConnectTimeout(15L, TimeUnit.SECONDS);
paramOkHttpClient.setReadTimeout(20L, TimeUnit.SECONDS);
paramOkHttpClient.setWriteTimeout(20L, TimeUnit.SECONDS);
this.a = paramOkHttpClient;
this.b = paramMediaCache;
this.c = paramContext;
}
public final Downloader.Response load(Uri paramUri, int paramInt)
throws IOException
{
Object localObject = new Request.Builder().url(paramUri.toString()).addHeader("Bitmoji-User-Agent", WebUtils.getBitmojiUserAgent(this.c)).build();
localObject = this.a.newCall((Request)localObject).execute();
int i = ((Response)localObject).code();
if (i >= 300)
{
((Response)localObject).body().close();
throw new Downloader.ResponseException(i + " " + ((Response)localObject).message(), paramInt, i);
}
localObject = ((Response)localObject).body();
paramUri = this.b.storeMediaData(paramUri.toString(), ((ResponseBody)localObject).byteStream());
if (paramUri == null) {
return new Downloader.Response(((ResponseBody)localObject).byteStream(), false, ((ResponseBody)localObject).contentLength());
}
return new Downloader.Response(new FileInputStream(paramUri), false, ((ResponseBody)localObject).contentLength());
}
public final void shutdown()
{
this.b.shutdown();
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/hm.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/