|
|
|
|
@ -114,6 +114,16 @@ public class ApiConfig { |
|
|
|
|
return json; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static byte[] getImgJar(String body){ |
|
|
|
|
Pattern pattern = Pattern.compile("[A-Za-z0]{8}\\*\\*"); |
|
|
|
|
Matcher matcher = pattern.matcher(body); |
|
|
|
|
if(matcher.find()){ |
|
|
|
|
body = body.substring(body.indexOf(matcher.group()) + 10); |
|
|
|
|
return Base64.decode(body, Base64.DEFAULT); |
|
|
|
|
} |
|
|
|
|
return "".getBytes(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void loadConfig(boolean useCache, LoadConfigCallback callback, Activity activity) { |
|
|
|
|
String apiUrl = Hawk.get(HawkConfig.API_URL, ""); |
|
|
|
|
if (apiUrl.isEmpty()) { |
|
|
|
|
@ -229,6 +239,8 @@ public class ApiConfig { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
boolean isJarInImg = jarUrl.startsWith("img+"); |
|
|
|
|
jarUrl = jarUrl.replace("img+", ""); |
|
|
|
|
OkGo.<File>get(jarUrl) |
|
|
|
|
.headers("User-Agent", userAgent) |
|
|
|
|
.headers("Accept", requestAccept) |
|
|
|
|
@ -242,7 +254,13 @@ public class ApiConfig { |
|
|
|
|
if (cache.exists()) |
|
|
|
|
cache.delete(); |
|
|
|
|
FileOutputStream fos = new FileOutputStream(cache); |
|
|
|
|
fos.write(response.body().bytes()); |
|
|
|
|
if(isJarInImg) { |
|
|
|
|
String respData = response.body().string(); |
|
|
|
|
byte[] imgJar = getImgJar(respData); |
|
|
|
|
fos.write(imgJar); |
|
|
|
|
} else { |
|
|
|
|
fos.write(response.body().bytes()); |
|
|
|
|
} |
|
|
|
|
fos.flush(); |
|
|
|
|
fos.close(); |
|
|
|
|
return cache; |
|
|
|
|
|