使用这张图片:
1.您可以使用一个活动和一个片段作为视图。
public class AuthenticationActivity extends BaseActivity implements AuthenticationPatternFragment.NavigateToDashboardCallback,
AuthenticationPasswordFragment.NavigateToDashboardCallback {}
public class AuthenticationPasswordFragment extends Fragment implements AuthenticationContract.View {}
-- 更适合你有一个小活动,并在活动中实现组件只是导航抽屉、工具栏、.. 和片段中的其他组件。
2.使用一个类作为连接到存储库的演示者。
3.使用类作为获取、设置、getAll、更新本地数据库和远程服务器中的数据的存储库。
public class AuthenticationRepository implements IAuthenticationRepository {
private IAuthenticationRepository mAuthenticationRealmRepository;
private IAuthenticationRepository mAuthenticationRestRepository;
public AuthenticationRepository(IAuthenticationRepository restRepository, IAuthenticationRepository realmRepository) {
mAuthenticationRestRepository = restRepository;
mAuthenticationRealmRepository = realmRepository;
}
private AuthenticationRepository() {
}
@Override
public void get(CallRepository<Authentication> callRepository) {
mAuthenticationRealmRepository.get(callRepository);
}
@Override
public void update(Authentication authentication, CallRepository<Authentication> callRepository) {
mAuthenticationRealmRepository.update(authentication, callRepository);
}
@Override
public void get(Integer identifier, CallRepository<Authentication> callRepository) {
mAuthenticationRealmRepository.get(identifier, callRepository);
}
@Override
public void getAll(CallRepository<List<Authentication>> callRepository) {
mAuthenticationRealmRepository.getAll(callRepository);
}
}
4.将包创建为模型,您可以在其上导入所有模型。
5.您可以创建 ClassNameContract 作为接口,以定义另外两个接口作为视图和演示者,如下所示:
public interface AuthenticationContract {
interface View extends BaseView<Presenter>{
}
interface Presenter extends BasePresenter{
}
---------You can use this example for better review in MVP