Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevents multiple calling of showing dialog #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class NotifyDialog extends Dialog {
public enum Type{
INFO, CONFIRM
}
private static boolean showing = false;

/**
* start info dialog with one button
Expand Down Expand Up @@ -49,15 +50,17 @@ public static NotifyDialog startConfirm(Context context, String title, String te
public NotifyDialog(Context context, String title, String text, Type type) {
super(context, R.style.Theme_Dialog);

setCancelable(false);
setCanceledOnTouchOutside(false);
if (!showing) {
setCancelable(false);
setCanceledOnTouchOutside(false);

titleStr = title;
textStr = text;
this.type = type;

show();
titleStr = title;
textStr = text;
this.type = type;

showing = true;
show();
}
}

/**
Expand Down Expand Up @@ -103,6 +106,7 @@ private void setOneButtonOptions() {
buttonOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showing = false;
if(oneButtonListener != null){
oneButtonListener.onOkClicked(NotifyDialog.this);
}else{
Expand All @@ -124,6 +128,7 @@ private void setTwoButtonOptions() {
buttonOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showing = false;
if (twoButtonListener != null) {
twoButtonListener.onOkClicked(NotifyDialog.this);
} else {
Expand All @@ -136,6 +141,7 @@ public void onClick(View v) {
buttonCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showing = false;
if(twoButtonListener != null){
twoButtonListener.onCancelClicked(NotifyDialog.this);
}else{
Expand Down