I'm trying to develop an Android app following MVP pattern so I can separate the views from the logic of the application.
So let's put an example in order to illustrate my doubts.
public interface IView {
public void showToast(String text);
}
public class Presenter() {
View view;
public presenter(View _view) {
view = _view;
}
public void setCustomToast(String text) {
view.showToast("hello");
}
}
public class View implements IView {
Public void showToast(String text) {
Toast.makeText(getApplicationContext(), text, LENGTH_LONG).show();
}
}
Why the interface gives abstraction and allow to separate code? Without the interface wouldn't it work the same?