//LoginPresenter
public class LoginPresenter implements IPresenterLogin{ private IViewLogin iViewLogin; private final LoginModel regModel; public LoginPresenter(IViewLogin iViewLogin) { this.iViewLogin = iViewLogin; regModel = new LoginModel(this); } public void getData(String loginUrl, String umobile, String upwd) { regModel.getData(loginUrl,umobile,upwd); } @Override public void onSuccess(JSONObject obj) { iViewLogin.onSuccess(obj); } @Override public void onFailure(String error) { iViewLogin.onFailed(error); } }//RegistPresenter
public class RegistPresenter implements IPresenterRegist{private IViewRegist iViewRegist; private final RegistModel registModel; public RegistPresenter(IViewRegist iViewRegist) { this.iViewRegist = iViewRegist; registModel = new RegistModel(this); } public void getData(String loginUrl, String umobile, String upwd) { registModel.getData(loginUrl,umobile,upwd); } @Override public void onSuccess(JSONObject obj) { iViewRegist.onSuccess(obj); } @Override public void onFailed(String error) { iViewRegist.onFailed(error); } }
//SearchPresenterpublic class SearchPresenter implements IPresenterSearch{ SearchModel searchModel = new SearchModel(this); private IViewSearch iViewSearch; public SearchPresenter(IViewSearch iViewSearch) { this.iViewSearch = iViewSearch; } public void getData(String searchUrl, String keywords) { searchModel.getData(searchUrl,keywords); } @Override public void onSuccess(AllContent allContent) { iViewSearch.onSuccess(allContent); } }
//interfacepublic interface IPresenterLogin {void onSuccess(JSONObject obj); void onFailure(String message); }public interface IPresenterRegist { void onSuccess(JSONObject obj); void onFailed(String error); }public interface IPresenterSearch { void onSuccess(AllContent allContent); }