{"action":"closed","issue":{"url":"https://api.github.com/repos/iMeiji/Toutiao/issues/30","repository_url":"https://api.github.com/repos/iMeiji/Toutiao","labels_url":"https://api.github.com/repos/iMeiji/Toutiao/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/iMeiji/Toutiao/issues/30/comments","events_url":"https://api.github.com/repos/iMeiji/Toutiao/issues/30/events","html_url":"https://github.com/iMeiji/Toutiao/issues/30","id":292669996,"number":30,"title":"感谢楼主的分享，请问下楼主这个类LazyLoadFragment的作用","user":{"login":"superxsx","id":32897328,"avatar_url":"https://avatars0.githubusercontent.com/u/32897328?v=4","gravatar_id":"","url":"https://api.github.com/users/superxsx","html_url":"https://github.com/superxsx","followers_url":"https://api.github.com/users/superxsx/followers","following_url":"https://api.github.com/users/superxsx/following{/other_user}","gists_url":"https://api.github.com/users/superxsx/gists{/gist_id}","starred_url":"https://api.github.com/users/superxsx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superxsx/subscriptions","organizations_url":"https://api.github.com/users/superxsx/orgs","repos_url":"https://api.github.com/users/superxsx/repos","events_url":"https://api.github.com/users/superxsx/events{/privacy}","received_events_url":"https://api.github.com/users/superxsx/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-01-30T06:44:46Z","updated_at":"2018-02-23T06:10:50Z","closed_at":"2018-02-23T06:10:50Z","author_association":"NONE","body":"public abstract class LazyLoadFragment<T extends IBasePresenter> extends BaseFragment<T> {\r\n\r\n    protected boolean isViewInitiated;\r\n    protected boolean isVisibleToUser;\r\n    protected boolean isDataInitiated;\r\n\r\n    @Override\r\n    public void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n    }\r\n\r\n    @Override\r\n    public void onActivityCreated(Bundle savedInstanceState) {\r\n        super.onActivityCreated(savedInstanceState);\r\n        isViewInitiated = true;\r\n        prepareFetchData();\r\n    }\r\n\r\n    @Override\r\n    public void setUserVisibleHint(boolean isVisibleToUser) {\r\n        super.setUserVisibleHint(isVisibleToUser);\r\n        this.isVisibleToUser = isVisibleToUser;\r\n        prepareFetchData();\r\n    }\r\n\r\n    public abstract void fetchData();\r\n\r\n    public boolean prepareFetchData() {\r\n        return prepareFetchData(false);\r\n    }\r\n\r\n    public boolean prepareFetchData(boolean forceUpdate) {\r\n        if (isVisibleToUser && isViewInitiated && (!isDataInitiated || forceUpdate)) {\r\n            fetchData();\r\n            isDataInitiated = true;\r\n            return true;\r\n        }\r\n        return false;\r\n    }\r\n\r\n}\r\n\r\n是为了保证只加载一次Fragment? 然后一个Fragment只调用一次fetchData()方法进行注册？\r\n\r\n"}}
{"actor":{"display_login":"iMeiji"}}