javiersantos / AppUpdater

A library that checks for your apps' updates on Google Play, GitHub, Amazon, F-Droid or your own server. API 9+ required.
Apache License 2.0
1.98k stars 412 forks source link

Separate Update and No Update notification #92

Closed ghost closed 7 years ago

ghost commented 7 years ago

Thanks for the great lib. I was wondering is there a way to separate the Update and No Update portion of the code? I would like to change the No Update notification to a snack bar and leave the Update notification as a dialog. Or just stop the No Update notification.

javiersantos commented 7 years ago

It is not possible when using the AppUpdater builder, but you can use the AppUpdaterUtils builder instead and show a dialog or snackbar based on the results. For example:

AppUpdaterUtils appUpdaterUtils = new AppUpdaterUtils(this)
    //.setUpdateFrom(UpdateFrom.AMAZON)
    //.setUpdateFrom(UpdateFrom.GITHUB)
    //.setGitHubUserAndRepo("javiersantos", "AppUpdater")
    //...
    .withListener(new AppUpdaterUtils.UpdateListener() {
        @Override
        public void onSuccess(Update update, Boolean isUpdateAvailable) {
           if (isUpdateAvailable) {
              // Show a Dialog
           } else {
              // Show a Snackbar
           }
        }

        @Override
        public void onFailed(AppUpdaterError error) {
            Log.d("AppUpdater Error", "Something went wrong");
        }
     });
appUpdaterUtils.start();