Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

看了源码,写得不错,有个疑问,这个框架是否只支持一次状态切换 #1

Open
callmenero opened this issue Jun 12, 2019 · 2 comments

Comments

@callmenero
Copy link

callmenero commented Jun 12, 2019

从给的例子里面就可以看到,常规使用界面,初始失败状态,点击加载成功后,下拉刷新走到失败的处理,但是并不会导致状态切换,代码里面用一个Map存储了view的加载状态,只在第一次调用load方法后保存为true,并且替换了布局,后面再调用该方法:

都不会替换布局,是否是刻意为之,以上

@callmenero
Copy link
Author

public void onFailed(View view, Class<? extends BaseLoadRetryAdapter> cla, Object object) {
if (isRegister(view)) {
if (isHasAdapter(cla)) {
if (!viewLoadSuccess.get(System.identityHashCode(view))) {
coverLayoutHashMap.get(System.identityHashCode(view)).onFailed(cla, object);
}
}
}
}

@aiceking
Copy link
Owner

这个是刻意的,这个状态的关联是当前View第一次有没有数据,只要没有数据,User调用onFailed就会一直根据你传递的adapter来切换布局,反之,初次加载也好,retry也好,只要有一次onSuccess了,这种情况下就不会再替换任何的布局了,原因很简单,这个框架的目的简单粗暴来说,就是为了初次加载没数据的情况下遮罩一下,比如说有了数据了,遮罩消失,再下拉刷新后没有数据了,这种情况下Toast一下就行,没必要突兀的再把遮罩显示回来,这样用户体验会好,另外,初次加载遮罩也是这个目的,我把布局遮住了,就不需要判断布局里的各种操作会不会空指针,布局展示出来了,他就一定有数据了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants