fix: add debug toasts and remove cache for nursing info API call
- Remove CacheMode.REQUEST_FAILED_READ_CACHE to eliminate cache issues - Add detailed toast messages for each failure scenario - Toast success count when data loads Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -153,7 +153,7 @@ public class HomeFragment extends BaseFragment {
|
||||
private void initNursingInfo() {
|
||||
OkGo.<String>get(HttpConstants.URi_system_getAppIndexInfo)
|
||||
.converter(new StringConvert())
|
||||
.cacheMode(CacheMode.REQUEST_FAILED_READ_CACHE)
|
||||
.cacheMode(CacheMode.NO_CACHE)
|
||||
.adapt(new ObservableResponse<String>())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@@ -165,9 +165,18 @@ public class HomeFragment extends BaseFragment {
|
||||
@Override
|
||||
public void onNext(@NonNull Response<String> response) {
|
||||
String body = (String) response.body();
|
||||
Log.e("护理资讯", body);
|
||||
Log.e("护理资讯", "code=" + response.code() + " body=" + body);
|
||||
if (body == null || body.isEmpty()) {
|
||||
toast("护理资讯返回为空");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
JSONObject json = JSON.parseObject(body);
|
||||
int code = json.getIntValue("code");
|
||||
if (code != 200) {
|
||||
toast("护理资讯code=" + code);
|
||||
return;
|
||||
}
|
||||
JSONObject data = json.getJSONObject("data");
|
||||
if (data != null) {
|
||||
JSONArray realTimeInfoList = data.getJSONArray("realTimeInfoList");
|
||||
@@ -184,18 +193,23 @@ public class HomeFragment extends BaseFragment {
|
||||
}
|
||||
robCustomerInfoBean.setNursingInfoList(list);
|
||||
adapter.notifyDataSetChanged();
|
||||
toast("护理资讯加载了" + list.size() + "条");
|
||||
} else {
|
||||
toast("realTimeInfoList为空");
|
||||
}
|
||||
} else {
|
||||
toast("data字段为null");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("护理资讯", "解析失败", e);
|
||||
toast("护理资讯数据异常");
|
||||
toast("护理资讯解析异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
e.printStackTrace();
|
||||
toast("加载护理资讯失败");
|
||||
Log.e("护理资讯", "网络错误", e);
|
||||
toast("加载护理资讯失败:" + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user