From 332131843f21564d12750a2aee29408cc96fab45 Mon Sep 17 00:00:00 2001 From: Joshua Date: Tue, 21 Sep 2021 22:09:36 +0200 Subject: [PATCH] dismiss listener bug fixed --- .../smartphonemouse/ui/connect/dialog/AddDialog.java | 5 +++-- .../smartphonemouse/ui/connect/dialog/InfoDialog.java | 8 +++++++- .../ui/settings/dialog/CalibrateDialog.java | 10 ++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/ch/virt/smartphonemouse/ui/connect/dialog/AddDialog.java b/app/src/main/java/ch/virt/smartphonemouse/ui/connect/dialog/AddDialog.java index 8db6a77..9939273 100644 --- a/app/src/main/java/ch/virt/smartphonemouse/ui/connect/dialog/AddDialog.java +++ b/app/src/main/java/ch/virt/smartphonemouse/ui/connect/dialog/AddDialog.java @@ -96,7 +96,6 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { created(); }); - dialog.setOnDismissListener(dismissListener); return dialog; } @@ -106,8 +105,9 @@ public void onDismiss(@NonNull DialogInterface dialog) { if (bluetoothHandler.getDiscoverer().isScanning()) bluetoothHandler.getDiscoverer().stopDiscovery(); super.onDismiss(dialog); - } + dismissListener.onDismiss(dialog); + } /** * This method gets called when the dialog is shown. @@ -281,6 +281,7 @@ public void onNext(){ case SUCCESS_STATE: case ALREADY_STATE: dismiss(); + onDismiss(getDialog()); } } diff --git a/app/src/main/java/ch/virt/smartphonemouse/ui/connect/dialog/InfoDialog.java b/app/src/main/java/ch/virt/smartphonemouse/ui/connect/dialog/InfoDialog.java index 54e0b2d..d5a95cd 100644 --- a/app/src/main/java/ch/virt/smartphonemouse/ui/connect/dialog/InfoDialog.java +++ b/app/src/main/java/ch/virt/smartphonemouse/ui/connect/dialog/InfoDialog.java @@ -62,6 +62,13 @@ public void setOnDismissListener(DialogInterface.OnDismissListener dismissListen this.dismissListener = dismissListener; } + @Override + public void onDismiss(@NonNull DialogInterface dialog) { + super.onDismiss(dialog); + + dismissListener.onDismiss(dialog); + } + @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { @@ -78,7 +85,6 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { Dialog dialog = builder.create(); dialog.setTitle(R.string.dialog_info_title); - dialog.setOnDismissListener(dismissListener); return dialog; } diff --git a/app/src/main/java/ch/virt/smartphonemouse/ui/settings/dialog/CalibrateDialog.java b/app/src/main/java/ch/virt/smartphonemouse/ui/settings/dialog/CalibrateDialog.java index c209a7a..b874bc6 100644 --- a/app/src/main/java/ch/virt/smartphonemouse/ui/settings/dialog/CalibrateDialog.java +++ b/app/src/main/java/ch/virt/smartphonemouse/ui/settings/dialog/CalibrateDialog.java @@ -7,6 +7,7 @@ import android.view.LayoutInflater; import android.widget.Button; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; @@ -83,8 +84,13 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { created(); }); - dialog.setOnDismissListener(finishedListener); - return dialog; } + + @Override + public void onDismiss(@NonNull DialogInterface dialog) { + super.onDismiss(dialog); + + finishedListener.onDismiss(dialog); + } }