Closed TomasKypta closed 5 years ago
... or we should have first talked about the observer callback naming - the correct one is onYouCanContinueFriendlyDeveloper()
. This would emphasize that from our consumer developer perspective, the network activity and updates are irrelevant and should be hidden...
On the other hand, if we just add UpdateType
to the onUpdateFinished
method, it will work and in a way, the API will give our developer more control. We can also then implement class alongside these lines:
public class DefaultUpdateObserver implements UpdateObserver {
public void onUpdateStarted(UpdateType type) {
if (type == UpdateType.SILENT || type == UpdateType.NO_UPDATE) {
runTask(); // run the task now...
}
}
public void onUpdateFinished(UpdateType type, UpdateResult result) {
if (result == UpdateResult.OK) {
if (UpdateType == UpdateType.DIRECT) {
runTask(); // run the task later
}
}
}
public abstract void runTask();
}
OK, I can we can extend onUpdateFinished
. It's not necessary, you can easily work around it, but it simplifies things for the devs. And the default is some a nice to have.
Add observers for updates and global observers for validation failures. Change update method to be asynchronous with observer. Add method for checking if update is necessary (without invoking the update).