-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Milestone
Description
We have a lot of code like this:
mHandler.getOperation().observe(this, new Observer<Resource<IdpResponse>>() {
@Override
public void onChanged(Resource<IdpResponse> resource) {
if (resource.getState() == State.LOADING) {
getDialogHolder().showLoadingDialog(R.string.fui_progress_dialog_signing_in);
return;
}
getDialogHolder().dismissDialog();
if (resource.getState() == State.SUCCESS) {
// ...
} else if (resource.getState() == State.FAILURE) {
// ...
}
}
});In particular the LOADING bits almost always look the same. We could make something like:
public class ResourceObserver<T> extends Observer<Resource<T>> {
@Override
public void onChanged(Resource<T> resource) {
if (resource.getState() == State.LOADING) {
onLoading()
} else {
onNotLoading(resource);
}
}
protected void onLoading() {
// .. Do standard stuf
}
protected abstract void onNotLoading(...);
}Reactions are currently unavailable