use of com.frostwire.android.gui.dialogs.SoftwareUpdaterDialog in project frostwire by frostwire.
the class SoftwareUpdater method notifyUserAboutUpdate.
public void notifyUserAboutUpdate(final MainActivity activity) {
try {
if (update.a == null) {
// make it the old behavior
update.a = UPDATE_ACTION_OTA;
}
if (update.a.equals(UPDATE_ACTION_OTA)) {
if (!ALWAYS_SHOW_UPDATE_DIALOG && !getUpdateApk().exists()) {
LOG.info("notifyUserAboutUpdate(): " + getUpdateApk().getAbsolutePath() + " not found. Aborting.");
return;
}
// Fresh runs with fast connections might send the broadcast intent before
// MainActivity has had a chance to register the broadcast receiver (onResume)
// therefore, the menu update icon will only show on the 2nd run only
activity.updateNavigationMenu(true);
SoftwareUpdaterDialog dlg = SoftwareUpdaterDialog.newInstance(update.updateMessages, update.changelog);
dlg.show(activity.getFragmentManager());
} else if (update.a.equals(UPDATE_ACTION_MARKET)) {
String message = StringUtils.getLocaleString(update.marketMessages, activity.getString(R.string.update_message));
UIUtils.showYesNoDialog(activity.getFragmentManager(), message, R.string.update_title, (dialog, which) -> {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(update.m));
activity.startActivity(intent);
});
}
} catch (Throwable e) {
LOG.error("Failed to notify update", e);
// try again next time MainActivity is resumed
updateTimestamp = -1;
}
}
Aggregations