Closed TonyTangAndroid closed 7 years ago
Hi @TonyTangAndroid!
The idea of making CleanActivity
implement BaseView
is to allow BaseFragment
(which also implements it) to delegate some methods to its parent activity. But there is an error: instead of casting the activity to BaseView
, the cast is done to CleanActivity
, losing the benefits of the interface...
@Override
public void close() {
((CleanActivity)getActivity()).close();
}
must be replaced with:
@Override
public void close() {
((BaseView)getActivity()).close();
}
as well as all the BaseView
methods called on CleanActivity
.
I see. No wonder. It makes sense. Thank you again.
Hi Jordi, it's me again. I have been pushing myself working my project to clean architecture and things become clearer and clearer. But there are still mysteries that I am wondering. For example,
Why CleanActivity.java needs to implement BaseView.java interface?
If I remove the interface implementation and the override annotation, everything will still works okay. I get a feeling that there must be a reason that rationales you making this decision. But I fail in figuring it out. Could you kindly please elaborate it for me?
I have created a pull request to my own forked project just to demonstrate the difference with our without the interface implementation. You could refer the pull request here:
https://github.com/TonyTangAndroid/android-base/pull/4/files