diff --git a/README.md b/README.md index fc00b47..2b7414c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Add this to your module's `build.gradle` file: ```gradle dependencies { ... - implementation 'com.github.Dan629pl:NordanMaterialDialog:1.0.2' + implementation 'com.github.Dan629pl:NordanMaterialDialog:1.0.3' } ```

Nordan Alert Dialog

@@ -26,7 +26,7 @@ dependencies { .setMessage("Your message") .setPositiveBtnText("Ok") .setNegativeBtnText("Cancel") - .setIcon(R.drawable.your_drawable) + .setIcon(R.drawable.your_drawable,false) .setBackgroundColor(R.color.red) .onPositiveClicked(() -> {/* Do something here */}) .onNegativeClicked(() -> {/* Do something here */}) @@ -56,6 +56,22 @@ dependencies { .build().show(); ``` +

Dialog with Gif icon

+ +```diff + new NordanAlertDialog.Builder(this) + .setAnimation(Animation.SLIDE) + .isCancellable(false) + .setTitle("Gif Icon") + .setMessage("Library support gif icons!") + .setIcon(R.drawable.success_gif,true) + .setPositiveBtnText("Great!") + .onPositiveClicked(this::showAll) + .build().show(); +``` +![Gif Dialog](https://github.com/Dan629pl/NordanMaterialDialog/blob/master/img/gifdialog.gif) + +

Nordan Loading Dialog

```diff diff --git a/app/src/main/java/com/nordan/dialog/NordanAlertDialog.java b/app/src/main/java/com/nordan/dialog/NordanAlertDialog.java index 2d6e7b8..e312488 100644 --- a/app/src/main/java/com/nordan/dialog/NordanAlertDialog.java +++ b/app/src/main/java/com/nordan/dialog/NordanAlertDialog.java @@ -6,6 +6,8 @@ import android.graphics.drawable.ColorDrawable; import android.view.View; import android.view.Window; +import android.widget.ImageView.ScaleType; +import android.widget.RelativeLayout; import com.google.android.material.button.MaterialButton; import com.google.android.material.textview.MaterialTextView; import java.util.Optional; @@ -25,6 +27,7 @@ public static class Builder { private Activity activity; private Animation animation; private int icon; + private boolean isGif; private NordanAlertDialogListener positiveListener; private NordanAlertDialogListener negativeListener; private int backgroundColor; @@ -65,8 +68,9 @@ public Builder setNegativeBtnText(String negativeBtnText) { return this; } - public Builder setIcon(int icon) { + public Builder setIcon(int icon, boolean isGif) { this.icon = icon; + this.isGif = isGif; return this; } @@ -194,13 +198,18 @@ private void setInformationDialog(GifImageView iconImg, View view) { } private void setCustomDialog(Dialog dialog, GifImageView iconImg, View view) { + RelativeLayout relativeHeader = dialog.findViewById(R.id.relative_header); if (icon == 0 && backgroundColor == 0) { - dialog.findViewById(R.id.relative_header).setVisibility(View.GONE); + relativeHeader.setVisibility(View.GONE); return; } if (icon != 0) { iconImg.setImageResource(icon); iconImg.setVisibility(View.VISIBLE); + if (isGif) { + relativeHeader.getLayoutParams().height = 250; + iconImg.setScaleType(ScaleType.CENTER_CROP); + } } if (backgroundColor != 0) { view.setBackgroundColor(backgroundColor); diff --git a/app/src/main/res/layout/nordan_alert_dialog.xml b/app/src/main/res/layout/nordan_alert_dialog.xml index 543eb3d..bab98b3 100644 --- a/app/src/main/res/layout/nordan_alert_dialog.xml +++ b/app/src/main/res/layout/nordan_alert_dialog.xml @@ -19,16 +19,17 @@ + android:layout_height="wrap_content"> diff --git a/img/gifdialog.gif b/img/gifdialog.gif new file mode 100644 index 0000000..8e38394 Binary files /dev/null and b/img/gifdialog.gif differ