@@ -0,0 +1,2058 @@
+package com.jess.arms.base;%0A%0Aimport android.support.v4.app.Fragment;%0Aimport android.support.v4.app.FragmentManager;%0A%0Aimport com.jess.arms.mvp.IPresenter;%0A%0Aimport java.util.List;%0A%0A/**%0A * %E5%AD%90%E7%B1%BB%E8%A6%86%E5%86%99%7B@link BaseLazyLoadFragment%7DlazyLoadData%E5%8F%AF%E5%BF%AB%E9%80%9F%E5%AE%9E%E7%8E%B0Fragment%E6%87%92%E5%8A%A0%E8%BD%BD%0A */%0Apublic abstract class BaseLazyLoadFragment%3CP extends IPresenter%3E extends BaseFragment%3CP%3E %7B%0A%0A    private boolean isViewCreated; // %E7%95%8C%E9%9D%A2%E6%98%AF%E5%90%A6%E5%B7%B2%E5%88%9B%E5%BB%BA%E5%AE%8C%E6%88%90%0A    private boolean isVisibleToUser; // %E6%98%AF%E5%90%A6%E5%AF%B9%E7%94%A8%E6%88%B7%E5%8F%AF%E8%A7%81%0A    private boolean isDataLoaded; // %E6%95%B0%E6%8D%AE%E6%98%AF%E5%90%A6%E5%B7%B2%E8%AF%B7%E6%B1%82%0A%0A    /**%0A     * %E6%AD%A4%E5%A4%84%E5%AE%9E%E7%8E%B0%E5%85%B7%E4%BD%93%E7%9A%84%E6%95%B0%E6%8D%AE%E8%AF%B7%E6%B1%82%E9%80%BB%E8%BE%91%0A     */%0A    public abstract void lazyLoadData();%0A%0A    @Override%0A    public void setUserVisibleHint(boolean isVisibleToUser) %7B%0A        super.setUserVisibleHint(isVisibleToUser);%0A        this.isVisibleToUser = isVisibleToUser;%0A        tryLoadData();%0A    %7D%0A%0A    /**%0A     * %E4%BF%9D%E8%AF%81%E5%9C%A8initData%E5%90%8E%E8%A7%A6%E5%8F%91%0A     */%0A    @Override%0A    public void onResume() %7B%0A        super.onResume();%0A        isViewCreated = true;%0A        tryLoadData();%0A    %7D%0A%0A    /**%0A     * ViewPager%E5%9C%BA%E6%99%AF%E4%B8%8B%EF%BC%8C%E5%88%A4%E6%96%AD%E7%88%B6fragment%E6%98%AF%E5%90%A6%E5%8F%AF%E8%A7%81%0A     */%0A    private boolean isParentVisible() %7B%0A        Fragment fragment = getParentFragment();%0A        return fragment == null %7C%7C (fragment instanceof BaseLazyLoadFragment && ((BaseLazyLoadFragment) fragment).isVisibleToUser);%0A    %7D%0A%0A    /**%0A     * ViewPager%E5%9C%BA%E6%99%AF%E4%B8%8B%EF%BC%8C%E5%BD%93%E5%89%8Dfragment%E5%8F%AF%E8%A7%81%E6%97%B6%EF%BC%8C%E5%A6%82%E6%9E%9C%E5%85%B6%E5%AD%90fragment%E4%B9%9F%E5%8F%AF%E8%A7%81%EF%BC%8C%E5%88%99%E8%AE%A9%E5%AD%90fragment%E8%AF%B7%E6%B1%82%E6%95%B0%E6%8D%AE%0A     */%0A    private void dispatchParentVisibleState() %7B%0A        FragmentManager fragmentManager = getChildFragmentManager();%0A        List%3CFragment%3E fragments = fragmentManager.getFragments();%0A        if (fragments.isEmpty()) %7B%0A            return;%0A        %7D%0A        for (Fragment child : fragments) %7B%0A            if (child instanceof BaseLazyLoadFragment && ((BaseLazyLoadFragment) child).isVisibleToUser) %7B%0A                ((BaseLazyLoadFragment) child).tryLoadData();%0A            %7D%0A        %7D%0A    %7D%0A%0A    public void tryLoadData() %7B%0A        if (isViewCreated && isVisibleToUser && isParentVisible() && !isDataLoaded) %7B%0A            lazyLoadData();%0A            isDataLoaded = true;%0A            //%E9%80%9A%E7%9F%A5%E5%AD%90Fragment%E8%AF%B7%E6%B1%82%E6%95%B0%E6%8D%AE%0A            dispatchParentVisibleState();%0A        %7D%0A    %7D%0A%7D

add lazyload fragment