android - 当另一个甜蜜警报显示时如何停止 SweetAlertDialog
问题描述
我有一个加载类型的甜蜜警报,在单击按钮后运行,这使用户等待数据 foreach 并在创建 PDF(使用服务器数据)后显示成功警报,但我发现第一个警报仍然显示。
btn_liste_clients.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SweetAlertDialog pDialog = new SweetAlertDialog(getContext(), SweetAlertDialog.PROGRESS_TYPE);
pDialog.getProgressHelper().setBarColor(Color.parseColor("#A5DC86"));
pDialog.setTitleText("Loading ...");
pDialog.setCancelable(true);
pDialog.show();
getclient("all");
}
});
call.enqueue(new Callback<List<col>>() {
@Override
public void onResponse(Call<List<col>> call, Response<List<col>> response) {
// mker = new ArrayList<>();
List<col> colList = response.body();for ( col c: colList){
Log.d("name : ",c.getNom_col());
Log.d("Lat : ",c.getLat_col());
Log.d("Long : ",c.getLong_col());
Log.d("Email : ",c.getEmailcol());
Log.d("type : ",c.getType());
Log.d("date : ",c.getDate_creation_col());
Log.d("Creator : ",c.getCreator());
Log.d("region : ",c.getRegion()+"");
if(c.getType().equals("vente")){
table.addCell(c.getNom_col());//
table.addCell(c.getEmailcol());//
table.addCell(c.getTel_fix_col());//
table.addCell(c.getTel_mobile_col());//
table.addCell(c.getRegion());//
table.addCell(c.getHeure_matin_col());//
table.addCell(c.getHeure_apresmatin_col());//
table.addCell(c.getCreator());//
}
}
try {
document.add(table);
} catch (DocumentException e) {
e.printStackTrace();
}
document.addCreationDate();
document.close();
// 1. Success message
new SweetAlertDialog(getActivity())
.setTitleText("votre liste a été créé avec succès!")
.show();
}
所以,伙计们,当成功警报显示时,我需要停止进度警报。
解决方案
尼斯问候!检查我下面的代码
SweetAlertDialog pDialog //declare this dialog globally
btn_liste_clients.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
pDialog = new SweetAlertDialog(getContext(), SweetAlertDialog.PROGRESS_TYPE);
pDialog.getProgressHelper().setBarColor(Color.parseColor("#A5DC86"));
pDialog.setTitleText("Loading ...");
pDialog.setCancelable(true);
pDialog.show();
getclient("all");
}
});
call.enqueue(new Callback<List<col>>() {
@Override
public void onResponse(Call<List<col>> call, Response<List<col>> response) {
// mker = new ArrayList<>();
List<col> colList = response.body();for ( col c: colList){
Log.d("name : ",c.getNom_col());
Log.d("Lat : ",c.getLat_col());
Log.d("Long : ",c.getLong_col());
Log.d("Email : ",c.getEmailcol());
Log.d("type : ",c.getType());
Log.d("date : ",c.getDate_creation_col());
Log.d("Creator : ",c.getCreator());
Log.d("region : ",c.getRegion()+"");
if(c.getType().equals("vente")){
table.addCell(c.getNom_col());//
table.addCell(c.getEmailcol());//
table.addCell(c.getTel_fix_col());//
table.addCell(c.getTel_mobile_col());//
table.addCell(c.getRegion());//
table.addCell(c.getHeure_matin_col());//
table.addCell(c.getHeure_apresmatin_col());//
table.addCell(c.getCreator());//
}
}
try {
document.add(table);
} catch (DocumentException e) {
e.printStackTrace();
}
document.addCreationDate();
document.close();
pDialog.dismiss(); //add this line here
// 1. Success message
new SweetAlertDialog(getActivity())
.setTitleText("votre liste a été créé avec succès!")
.show();
}
推荐阅读
- asp.net-core - 如何让 IdentityServer 与 AddDbContextPool 一起使用
- github - 在 PR 上使用的 Github Actions 分支
- javascript - 将字符串化的变量列表转换为 Javascript 中的字符串化变量列表
- azure - 如何使用 az cli 列出存储 blob url?
- python - 如何连接元组并将其放入单个项目列表中?
- ios - AVAudioSession 不会自动连接蓝牙 A2DP 音频?
- r - 用 ggplot 将 sigmoidal 曲线拟合到点
- java - 从字符串编译java源代码并将输出保存到流而不是文件
- python - 在 Databricks 中保存张量流模型
- batch-file - 通过带有bat(Windows)的Jenkins并使用Pipeline将提交消息字符串值保存在环境变量中?