Skip to content

Commit 0c98f59

Browse files
albendzneslihanturan
authored andcommitted
Do not create another dialog with the same custom view - reuse the old one (commons-app#3097)
* Clear parent from customView if parent is not null * Do not create a new dialog when a dialog with a custom view already exists on resume * remove debug code from dialog custom view parent investigation * Add rest file * Didn't mean to add that test file
1 parent d62afa1 commit 0c98f59

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/src/main/java/fr/free/nrw/commons/utils/DialogUtil.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ private static void showAlertDialog(Activity activity,
116116
final Runnable onNegativeBtnClick,
117117
View customView,
118118
boolean cancelable) {
119+
// If the custom view already has a parent, there is already a dialog showing with the view
120+
// This happens for on resume - return to avoid creating a second dialog - the first one
121+
// will still show
122+
if (customView != null && customView.getParent() != null) {
123+
return;
124+
}
125+
119126
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
120127
builder.setTitle(title);
121128
builder.setMessage(message);

0 commit comments

Comments
 (0)