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() {
|
private void initNursingInfo() {
|
||||||
OkGo.<String>get(HttpConstants.URi_system_getAppIndexInfo)
|
OkGo.<String>get(HttpConstants.URi_system_getAppIndexInfo)
|
||||||
.converter(new StringConvert())
|
.converter(new StringConvert())
|
||||||
.cacheMode(CacheMode.REQUEST_FAILED_READ_CACHE)
|
.cacheMode(CacheMode.NO_CACHE)
|
||||||
.adapt(new ObservableResponse<String>())
|
.adapt(new ObservableResponse<String>())
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
@@ -165,9 +165,18 @@ public class HomeFragment extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onNext(@NonNull Response<String> response) {
|
public void onNext(@NonNull Response<String> response) {
|
||||||
String body = (String) response.body();
|
String body = (String) response.body();
|
||||||
Log.e("护理资讯", body);
|
Log.e("护理资讯", "code=" + response.code() + " body=" + body);
|
||||||
|
if (body == null || body.isEmpty()) {
|
||||||
|
toast("护理资讯返回为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
JSONObject json = JSON.parseObject(body);
|
JSONObject json = JSON.parseObject(body);
|
||||||
|
int code = json.getIntValue("code");
|
||||||
|
if (code != 200) {
|
||||||
|
toast("护理资讯code=" + code);
|
||||||
|
return;
|
||||||
|
}
|
||||||
JSONObject data = json.getJSONObject("data");
|
JSONObject data = json.getJSONObject("data");
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
JSONArray realTimeInfoList = data.getJSONArray("realTimeInfoList");
|
JSONArray realTimeInfoList = data.getJSONArray("realTimeInfoList");
|
||||||
@@ -184,18 +193,23 @@ public class HomeFragment extends BaseFragment {
|
|||||||
}
|
}
|
||||||
robCustomerInfoBean.setNursingInfoList(list);
|
robCustomerInfoBean.setNursingInfoList(list);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
toast("护理资讯加载了" + list.size() + "条");
|
||||||
|
} else {
|
||||||
|
toast("realTimeInfoList为空");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
toast("data字段为null");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("护理资讯", "解析失败", e);
|
Log.e("护理资讯", "解析失败", e);
|
||||||
toast("护理资讯数据异常");
|
toast("护理资讯解析异常:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(@NonNull Throwable e) {
|
public void onError(@NonNull Throwable e) {
|
||||||
e.printStackTrace();
|
Log.e("护理资讯", "网络错误", e);
|
||||||
toast("加载护理资讯失败");
|
toast("加载护理资讯失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user