Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix okhttp 404 crash #109

Merged
merged 1 commit into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix okhttp 404 crash
  • Loading branch information
yaming116 committed Oct 13, 2019
commit f5367e4b353ce4a4587ab06af3f3f8b3114feb3c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public int compare(Entry o1, Entry o2) {
mGridView.setAdapter(adapter);

// 有写权限,申请下
PatchRequest.updatePatchList();
PatchRequest.updatePatchList(this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void onDialogPositive(List<String> data) {
mPatchListInfo.setText(path);

// 更新patch列表
PatchRequest.updatePatchList();
PatchRequest.updatePatchList(SettingsActivity.this);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class PatchRequest {
/**
* 更新Patch列表
*/
public static void updatePatchList() {
public static void updatePatchList(final BaseActivity activity) {
String storedUrl = SPService.getString(SPService.KEY_PATCH_URL, "https://raw.githubusercontent.com/alipay/SoloPi/master/<abi>.json");
// 地址为空
if (StringUtil.isEmpty(storedUrl)) {
Expand All @@ -87,6 +87,9 @@ public void onResponse(Call call, PatchResponse item) throws IOException {
@Override
public void onFailure(Call call, IOException e) {
LogUtil.e(TAG, "抛出IO异常," + e.getMessage(), e);
if (activity != null) {
activity.toastLong("Patch 更新异常,可能是cpu架构不支持 " + e.getMessage());
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ public Callback(Class<T> targetClass) {

@Override
public void onResponse(Call call, Response response) throws IOException {
if (!response.isSuccessful()) {
onFailure(call, new IOException(String.format("Received http response code %d", response.code())));
return;
}

ResponseBody body = response.body();

// 空对象直接空返回
Expand Down