diff --git a/app/src/main/java/com/nordan/dialog/DialogType.java b/app/src/main/java/com/nordan/dialog/DialogType.java index 088f6e7..127203f 100644 --- a/app/src/main/java/com/nordan/dialog/DialogType.java +++ b/app/src/main/java/com/nordan/dialog/DialogType.java @@ -4,7 +4,6 @@ public enum DialogType { WARNING, ERROR, INFORMATION, - NO_HEADER, QUESTION, SUCCESS } diff --git a/app/src/main/java/com/nordan/dialog/NordanAlertDialog.java b/app/src/main/java/com/nordan/dialog/NordanAlertDialog.java index 8f1a7c9..a486611 100644 --- a/app/src/main/java/com/nordan/dialog/NordanAlertDialog.java +++ b/app/src/main/java/com/nordan/dialog/NordanAlertDialog.java @@ -9,13 +9,13 @@ import com.google.android.material.button.MaterialButton; import com.google.android.material.textview.MaterialTextView; import java.util.Optional; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import pl.droidsonroids.gif.GifImageView; +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class NordanAlertDialog { - private NordanAlertDialog() { - } - public static class Builder { private String title; @@ -90,7 +90,7 @@ public Builder isCancellable(boolean cancel) { return this; } - public void show() { + public Dialog build() { final MaterialTextView messageDialog; final MaterialTextView titleDialog; final GifImageView iconImg; @@ -123,9 +123,6 @@ public void show() { case QUESTION: setQuestionDialog(iconImg, view); break; - case NO_HEADER: - setNoHeaderDialog(dialog); - break; case INFORMATION: setInformationDialog(iconImg, view); break; @@ -133,7 +130,7 @@ public void show() { setLevelCompleteDialog(iconImg, view); break; default: - setCustomDialog(iconImg, view); + setCustomDialog(dialog, iconImg, view); break; } } @@ -162,7 +159,7 @@ public void show() { } else { negativeButton.setOnClickListener(click -> dialog.dismiss()); } - dialog.show(); + return dialog; } private void setLevelCompleteDialog(GifImageView iconImg, View view) { @@ -189,17 +186,17 @@ private void setQuestionDialog(GifImageView iconImg, View view) { view.setBackgroundColor(activity.getColor(R.color.colorBlue)); } - private void setNoHeaderDialog(Dialog dialog) { - dialog.findViewById(R.id.relative_header).setVisibility(View.GONE); - } - private void setInformationDialog(GifImageView iconImg, View view) { iconImg.setImageResource(R.drawable.ic_baseline_info_24); iconImg.setVisibility(View.VISIBLE); view.setBackgroundColor(activity.getColor(R.color.colorPurple)); } - private void setCustomDialog(GifImageView iconImg, View view) { + private void setCustomDialog(Dialog dialog, GifImageView iconImg, View view) { + if (icon == 0 && backgroundColor == 0) { + dialog.findViewById(R.id.relative_header).setVisibility(View.GONE); + return; + } if (icon != 0) { iconImg.setImageResource(icon); iconImg.setVisibility(View.VISIBLE); diff --git a/img/default.jpg b/img/default.jpg deleted file mode 100644 index 85ddb2b..0000000 Binary files a/img/default.jpg and /dev/null differ diff --git a/img/dialogs_h.png b/img/dialogs_h.png deleted file mode 100644 index c61233f..0000000 Binary files a/img/dialogs_h.png and /dev/null differ diff --git a/img/dialogs_small.png b/img/dialogs_small.png deleted file mode 100644 index 337473c..0000000 Binary files a/img/dialogs_small.png and /dev/null differ diff --git a/img/error.jpg b/img/error.jpg deleted file mode 100644 index f0fede0..0000000 Binary files a/img/error.jpg and /dev/null differ diff --git a/img/information.jpg b/img/information.jpg deleted file mode 100644 index 1c86028..0000000 Binary files a/img/information.jpg and /dev/null differ diff --git a/img/no_header.jpg b/img/no_header.jpg deleted file mode 100644 index 2ab3064..0000000 Binary files a/img/no_header.jpg and /dev/null differ diff --git a/img/question.jpg b/img/question.jpg deleted file mode 100644 index 6efd065..0000000 Binary files a/img/question.jpg and /dev/null differ diff --git a/img/success.jpg b/img/success.jpg deleted file mode 100644 index 0e197a4..0000000 Binary files a/img/success.jpg and /dev/null differ