答案 0 :(得分:3)
很可能您已将sweetalert2依赖关系更新为^7.0.0
并且未阅读发布说明并进行了重大更改:https://github.com/sweetalert2/sweetalert2/releases/tag/v7.0.0
从v7.0.0
开始,SweetAlert2将履行确认和取消按钮的承诺,您需要以这种方式处理响应:
swal({
...
}).then(function (result) {
if (result.value) {
// handle confirm
} else {
// handle cancel
}
})
答案 1 :(得分:0)
参考:
https://jsfiddle.net/ad3quksn/199/
`
swal({
title: 'Input something',
type: 'question',
input: 'text',
showCancelButton: true
}).then(
result => {
if (result.value) {
swal({
type: 'success',
html: 'You entered: <strong>' + result.value + '</strong>'
})
} else {
console.log(`dialog was dismissed by ${result.dismiss}`)
}
}
);
`
从v7.0.0版本开始,它显示了如何处理承诺的输出示例:它帮助我更好地理解了!
答案 2 :(得分:0)
也许可以帮助您:
public void onBindViewHolder(@NonNull final Downloadsviewholder downloadsviewholder, final int i) {
downloadsviewholder.dName.setText(downloadsmodels.get(i).getName());
downloadsviewholder.dUploaddate.setText(downloadsmodels.get(i).getUploaddate());
downloadsviewholder.dExtension.setText(downloadsmodels.get(i).getFileextension());
Picasso.get().load(downloadsmodels.get(i).getIcon()).into(downloadsviewholder.dIcon);
downloadsviewholder.dButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (ConnectionCheck.checkconnetion(download_activity)) {
dowloadFile(downloadsviewholder.dName.getContext(), downloadsmodels.get(i).getName(), downloadsmodels.get(i).getFileextension()
, DIRECTORY_DOWNLOADS, downloadsmodels.get(i).getLink());
} else {
Toast.makeText(download_activity,"Check your internet connection", Toast.LENGTH_SHORT).show();
}
}
});
}
public void dowloadFile (Context context,String filename, String fileextension, String destinationdirectory, String url){
DownloadManager downloadManager=(DownloadManager) context.getSystemService(context.DOWNLOAD_SERVICE);
Uri uri=Uri.parse(url);
DownloadManager.Request request=new DownloadManager.Request(uri);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalFilesDir(context, destinationdirectory,filename+"."+fileextension);
downloadManager.enqueue(request);
}