如何在显示其他甜蜜警报时停止 SweetAlertDialog

how to stop SweetAlertDialog when an other sweet alert show

我有一个加载类型的甜蜜警报,运行 在单击按钮后让用户等待数据 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();
            }