java - 我在将数组列表返回到 downloadsurl() 方法时遇到问题
问题描述
我可以在 for 循环中为 URL 列表敬酒,但是当我尝试使用该downloadurls()
方法时,downloadlist 变量为空。
public static List<String> downloadUrls(Context context){
final List<DownloadData> downloadDataList= new ArrayList<>();
final List<String> downloadList= new ArrayList<>();
if (NetworkChangeReceiver.isNetworkConnected()){
Integer customerId = Integer.parseInt(AppPreference.getInstance(context).getString(PrefKey.CUSTOMER_ID));
ApiClient.getInstance().getApiInterface().getDownloadData(customerId).enqueue(new Callback<List<DownloadData>>() {
@Override
public void onResponse(Call<List<DownloadData>> call, Response<List<DownloadData>> response) {
if (response.isSuccessful() && response.body() != null){
downloadDataList.clear();
downloadDataList.addAll(response.body());
for (int i= 0; i<downloadDataList.size(); i++){
downloadList.clear();
downloadList.add(downloadDataList.get(i).getFileUrlData().getFile());
Toast.makeText(context, downloadList.toString(), Toast.LENGTH_SHORT).show();
}
}
}
@Override
public void onFailure(Call<List<DownloadData>> call, Throwable t) {
}
});
}
else {
Toast.makeText(context, "Please turn on Internet data bundles", Toast.LENGTH_SHORT).show;
}
return downloadList;
}
解决方案
推荐阅读
- reactjs - Facebook 可以将 React 许可证恢复为 BSD + 专利许可证吗?
- r - 列表中 ggplot 的第一个图总是错误的
- javascript - 从控制器返回消息到ajax请求jquery
- c - 使用 Switch case 删除 C 中字符串中的标点符号
- python - 如何使等于数字参数的键值出现
- javascript - 网络音频振荡器非常响亮?
- javascript - 隐藏的 JavaScript 负载
- macos - 修复 xnu 构建后的 kextcache“找不到符号”错误
- sql-server - 如果存在相同的值(例如给定的产品名称),如何在 SQL Server 中组合行?
- c# - 按钮文本在按下时更改,再次按下时更改回来