diff --git a/library/src/main/java/com/github/javiersantos/appupdater/AppUpdater.java b/library/src/main/java/com/github/javiersantos/appupdater/AppUpdater.java index d98ed887..a3ca191a 100644 --- a/library/src/main/java/com/github/javiersantos/appupdater/AppUpdater.java +++ b/library/src/main/java/com/github/javiersantos/appupdater/AppUpdater.java @@ -325,6 +325,27 @@ public AppUpdater init() { return this; } + @Override + public void showUpdateAvailable(Update update) { + switch (display) { + case DIALOG: + final DialogInterface.OnClickListener updateClickListener = btnUpdateClickListener == null ? new UpdateClickListener(context, updateFrom, update.getUrlToDownload()) : btnUpdateClickListener; + final DialogInterface.OnClickListener disableClickListener = btnDisableClickListener == null ? new DisableClickListener(context) : btnDisableClickListener; + + alertDialog = UtilsDisplay.showUpdateAvailableDialog(context, titleUpdate, getDescriptionUpdate(context, update, Display.DIALOG), btnDismiss, btnUpdate, btnDisable, updateClickListener, btnDismissClickListener, disableClickListener); + alertDialog.setCancelable(isDialogCancelable); + alertDialog.show(); + break; + case SNACKBAR: + snackbar = UtilsDisplay.showUpdateAvailableSnackbar(context, getDescriptionUpdate(context, update, Display.SNACKBAR), UtilsLibrary.getDurationEnumToBoolean(duration), updateFrom, update.getUrlToDownload()); + snackbar.show(); + break; + case NOTIFICATION: + UtilsDisplay.showUpdateAvailableNotification(context, titleUpdate, getDescriptionUpdate(context, update, Display.NOTIFICATION), updateFrom, update.getUrlToDownload(), iconResId); + break; + } + } + @Override public void start() { latestAppVersion = new UtilsAsync.LatestAppVersion(context, false, updateFrom, gitHub, xmlOrJsonUrl, new LibraryListener() { diff --git a/library/src/main/java/com/github/javiersantos/appupdater/interfaces/IAppUpdater.java b/library/src/main/java/com/github/javiersantos/appupdater/interfaces/IAppUpdater.java index e3112da7..39601876 100644 --- a/library/src/main/java/com/github/javiersantos/appupdater/interfaces/IAppUpdater.java +++ b/library/src/main/java/com/github/javiersantos/appupdater/interfaces/IAppUpdater.java @@ -378,6 +378,8 @@ public interface IAppUpdater { */ void start(); + void showUpdateAvailable(Update update); + /** * Stops the execution of AppUpdater. */