我们应该检查 Presenter 中的视图可见性还是 MVP 模式中的 Activity?
Should we check for view visibility in Presenter or Activity in MVP pattern?
所以,我正在遵循 MVP 模式,我将每个视图任务委托给演示者,这正是它应该完成的方式
例如。 :
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i1) {
if(textureView.getVisibility != View.GONE)
mPresenter.onSurfaceTextureAvailable(surfaceTexture);
}
我想知道是否允许在我的 activity(即 MVP 中的视图)中像这样直接检查视图的可见性?
谢谢!
View
层负责只向用户显示视图。它没有业务逻辑。 Presenter
层负责将数据从模型层呈现到视图层。它处理后台任务,调用模型上的操作并在视图中设置数据。您应该像这样在 Activity
中检查它。
public class YourActivity extends BaseActivity implements MainMvpView {
@Inject YourPresenter yourPresenter;
......
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i1) {
if(textureView.getVisibility != View.GONE)
mPresenter.onSurfaceTextureAvailable(surfaceTexture);
}
......
}
所以,我正在遵循 MVP 模式,我将每个视图任务委托给演示者,这正是它应该完成的方式
例如。 :
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i1) {
if(textureView.getVisibility != View.GONE)
mPresenter.onSurfaceTextureAvailable(surfaceTexture);
}
我想知道是否允许在我的 activity(即 MVP 中的视图)中像这样直接检查视图的可见性?
谢谢!
View
层负责只向用户显示视图。它没有业务逻辑。 Presenter
层负责将数据从模型层呈现到视图层。它处理后台任务,调用模型上的操作并在视图中设置数据。您应该像这样在 Activity
中检查它。
public class YourActivity extends BaseActivity implements MainMvpView {
@Inject YourPresenter yourPresenter;
......
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i1) {
if(textureView.getVisibility != View.GONE)
mPresenter.onSurfaceTextureAvailable(surfaceTexture);
}
......
}