java我在将arraylist返回downloadsurl()方法时遇到了一个问题
我可以在for循环中Toast 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;
}
共 (0) 个答案