I was doing R&D in MVP, and I am thinking of using this design template for my next project. But I ran into a problem with this design pattern.
Please see below java code.
I have a BaseActivity class
public class BaseActivity extends AppCompatActivity {
}
BaseView Interface
public interface BaseView {
void showLoader();
void hideLoader();
}
Another interface that extends the BaseView interface to maintain communication between views
public interface TestView extends BaseView {
void showResult();
}
Here is the final operation:
public class MyTestActivity extends BaseActivity implements TestView {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_test);
}
@Override
public void showLoader() {
}
@Override
public void hideLoader() {
}
@Override
public void showResult() {
}
}
The two showLoader () and HideLoader () methods from BaseView are common to each interface that extends BaseView. so I keep them in BaseView. no problem so far.
The problem is this: I have to implement and define the providers of these methods in each class that implements BaseView or its child interface.
Example: here in
TestActivity extends BaseActivity implements TestView
, , BaseView BaseActivity .
, BaseView TestActivity BaseActivity ( BaseView BaseActivity)
TestView, BaseView.
TestView BaseView.
BaseView BaseActivity, showLoader() hideLoader() Activity. 2 BaseView, ...
, .