i'm new in MVP
in android and after read many document about it i cant find some answers, for example i pasted some snippet from simple source on github
in this source we have three directory as model
, presenter
and view
; model folder have to interface class as :
public interface IUser {
String getName();
String getPasswd();
int checkUserValidity(String name, String passwd);
}
public class UserModel implements IUser {
String name;
String passwd;
public UserModel(String name, String passwd) {
this.name = name;
this.passwd = passwd;
}
@Override
public String getName() {
return name;
}
@Override
public String getPasswd() {
return passwd;
}
@Override
public int checkUserValidity(String name, String passwd){
if (name==null||passwd==null||!name.equals(getName())||!passwd.equals(getPasswd())){
return -1;
}
return 0;
}
}
comprehen problems:
why the programmer define two method of UserModel
on other interface
and then overrided into main class?
or into presenter
folder we have other interface
class.
whats compulsion to define methods on other interface and ovrride on main class?
public interface ILoginPresenter {
void clear();
void doLogin(String name, String passwd);
void setProgressBarVisiblity(int visiblity);
void onDestroy();
}
public class LoginPresenterCompl implements ILoginPresenter {
ILoginView iLoginView;
IUser user;
Handler handler;
public LoginPresenterCompl(ILoginView iLoginView) {
}
@Override
public void clear() {
}
@Override
public void doLogin(String name, String passwd) {
}
@Override
public void setProgressBarVisiblity(int visiblity){
}
@Override
public void onDestroy() {
}
private void initUser(){
}
}
and then in Activity
how do work this method:
@Override
protected void onDestroy() {
super.onDestroy();
loginPresenter.onDestroy();
}
onDestroy()
on loginPresenter
class is empty method !!!
Aucun commentaire:
Enregistrer un commentaire