Issue
When instantiating the NextcloudAPI we currently have some quite verbose code:
newNextcloudAPI(this, ssoAccount, newGsonBuilder().create(), newNextcloudAPI.ApiConnectedListener() {
@OverridepublicvoidonConnected() {
Log.i(TAG, "SSO API connected for " + ssoAccount);
}
@OverridepublicvoidonError(Exceptione) {
e.printStackTrace();
}
});The onConnected callback is usually quite useless, because according to the README.md the requests are queued anyway.
The onError callback might be more interesting, to handle exceptions more gracefully, use own loggers, etc.
Proposal
- Add a default implementation in
NextcloudAPI.ApiConnectedListener#onConnected which simply logs an info - Add a second constructor for
NextcloudAPI without an NextcloudAPI.ApiConnectedListener. This can internally call the original constructor and add some default default behavior like e.printStackTrace() in the onError callback.
This would allow 3rd party apps to reduce the boilerplate code to:
newNextcloudAPI(this, ssoAccount, newGsonBuilder().create(), Throwable::printStackTrace);
in the first case, and
newNextcloudAPI(this, ssoAccount, newGsonBuilder().create());
in the second, depending on the needs of the 3rd party app developer - while still providing all features of today and maintaining full backward compatibility.
Issue
When instantiating the
NextcloudAPIwe currently have some quite verbose code:The
onConnectedcallback is usually quite useless, because according to the README.md the requests are queued anyway.The
onErrorcallback might be more interesting, to handle exceptions more gracefully, use own loggers, etc.Proposal
NextcloudAPI.ApiConnectedListener#onConnectedwhich simply logs an infoNextcloudAPIwithout anNextcloudAPI.ApiConnectedListener. This can internally call the original constructor and add some default default behavior likee.printStackTrace()in theonErrorcallback.This would allow 3rd party apps to reduce the boilerplate code to:
in the first case, and
in the second, depending on the needs of the 3rd party app developer - while still providing all features of today and maintaining full backward compatibility.