weex
weex copied to clipboard
android list主动下拉刷新
我在ready方法里面调用了startRefresh方法,希望在页面渲染完毕时开始加载数据 we代码
module.exports = {
ready: function () {
require('@weex-module/TSLRefresh').beginRefresh(this.$el('list'));
},
}
TSLRefresh代码
@WXModuleAnno(moduleMethod = true, runOnUIThread = true)
public void beginRefresh(String ref) {
WXComponent listComponent =
WXSDKManager.getInstance()
.getWXRenderManager()
.getWXComponent(mWXSDKInstance.getInstanceId(), ref);
if(listComponent instanceof TSLListComponent) {
Log.d("refreshmoduel",ref);
((TSLListComponent) listComponent).getHostView().getSwipeLayout().startRefresh(0);
}
}
因为需求refresh在initComponentHostView里,我们自己做了UI的生成; 但是调试时候发现,先执行了主动刷新代码 然后再执行了refresh控件的initComponentHostView,也就是要开始刷新的时候控件还未生成完毕 想知道下这个list和refresh的生成过程是怎么样的? 如果要在页面生成后主动刷新,应该怎么做比较符合weex的设计思想
调用的时间点太早了,可以放在 appear事件