Your suggested implementation is a fine way to handle things. Although Loader
already presents callbacks for OnLoadComplete
and OnLoadCanceled
, so a started callback is the only addition you need to make. You could also implement a custom OnLoadStart
callback that triggers anytime onForceLoad()
or onStartLoad()
is called as opposed to loadInBackground
and it would more closely mirror the existing framework callbacks.
I would suggest that, just like the framework callbacks, you set up methods to register and unregister the listener rather than passing it in the constructor, so your Fragment can attach/remove itself as part of the normal lifecycle and the reference doesn't leak. As you mentioned, passing it in the constructor with no way to remove it would be considered a leak.