**就像SegmentFault的Android客户端
应用刚打开进入"问题", 就加在"问题"列表里面的数据
我点击"文章"在加载"文章"里面的数据.
正常逻辑是这样的.**
为什么我开发完
软件进入"问题"列表里面,是加载"问题"数据了.
当我点击"发现"按钮的时候, 我再点击"问题"按钮 又重新加载这个页面了,
然后我加上这句话, 整体逻辑都实现,
但是,我进入应用的时候, 他会把 问题, 文章, 发现都加载一遍.
这样并不是我需要的效果.
理想状态下是 软件打开的时候 进入 "问题", 我点击"发现"就加载发现, 我再添加"问题" 就不需要重新加载了.
fragment viewpage preloading problem
Reference link
http://www.2cto.com/kf/201501/368954.html
The effect is very similar, let’s open source it haha
To switch between fragments, use hide and show, and replace means remove and add, which will naturally reload
Because when you switch to the "problem" frgament again, onCreate and onCreateView will be called again, and your network request must be placed here, so there is nothing wrong if you don't reload.
My approach is to add a boolean value hasRequest
if (!hasRequest) {
Network request;
}
Then in the callback of successful network request, hasRequest = true;
No more loading multiple times