All Projects → xmagicj → Lazyfragment

xmagicj / Lazyfragment

类似微信,网易新闻 延迟加载Fragment基类 , 支持与ViewPager组合刷新全部Fragment

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Lazyfragment

Flowr
FlowR is a wrapper class around the Fragment Manager.
Stars: ✭ 123 (-68.54%)
Mutual labels:  fragments, fragment
Fragnav
An Android library for managing multiple stacks of fragments
Stars: ✭ 1,379 (+252.69%)
Mutual labels:  fragments, fragment
Fragmentrigger
💥A powerful library powered by AOP to manage Fragments.(一个基于AOP设计的Fragment管理框架)
Stars: ✭ 2,260 (+478.01%)
Mutual labels:  fragments, fragment
Tieguanyin
Activity Builder.
Stars: ✭ 113 (-71.1%)
Mutual labels:  fragments, fragment
Base
🍁 Base是针对于Android开发封装好一些常用的基类,主要包括通用的Adapter、Activity、Fragment、Dialog等、和一些常用的Util类,只为更简单。
Stars: ✭ 249 (-36.32%)
Mutual labels:  fragments, fragment
fragmenter
[Android Library] Remove Boilerplate code for initializing fragments
Stars: ✭ 62 (-84.14%)
Mutual labels:  fragments
StackOverFlowApi
working with Stack OverFlow Api
Stars: ✭ 24 (-93.86%)
Mutual labels:  fragments
GeneralRecyclerViewFragment
Can automatically pull down the refresh, pull up the page of RecyclerviewFragment(能够自动下拉刷新,上拉翻页的RecyclerviewFragment)
Stars: ✭ 56 (-85.68%)
Mutual labels:  fragment
solid
Solid Android components
Stars: ✭ 33 (-91.56%)
Mutual labels:  fragment
Android Switchdatetimepicker
Android library for Date and Time Picker in same dialog
Stars: ✭ 360 (-7.93%)
Mutual labels:  fragment
Altair
✨⚡️ A beautiful feature-rich GraphQL Client for all platforms.
Stars: ✭ 3,827 (+878.77%)
Mutual labels:  fragments
apollo-progressive-fragment-matcher
A smart alternative to the introspection fragment matcher.
Stars: ✭ 21 (-94.63%)
Mutual labels:  fragments
android-versioninfo
A version info widget for Android. Material style.
Stars: ✭ 21 (-94.63%)
Mutual labels:  fragments
Inlineactivityresult
Receive the activity result directly after the startActivityForResult with InlineActivityResult
Stars: ✭ 264 (-32.48%)
Mutual labels:  fragment
Smooth-Navigation
提供流畅的 Jetpack Navigation 转场体验。并解决 GitHub 上 Navigation Add Hide 修改版普遍存在的致命缺陷。
Stars: ✭ 204 (-47.83%)
Mutual labels:  fragment
Android Inline Youtube View
Utility library around using YouTube inside your android app.
Stars: ✭ 313 (-19.95%)
Mutual labels:  fragments
Prevailer-orientation-support-library-for-Android
Prevailer is a simple android library that helps in preserving object instances across orientation change in android and is JAVA 8 and MVP ready.
Stars: ✭ 17 (-95.65%)
Mutual labels:  fragments
mini-project
An android eCommerce application for students through which they can buy and sell used goods .
Stars: ✭ 26 (-93.35%)
Mutual labels:  fragments
Fragmentstack
A simple and easy to use a single Activity hosting multiple Fragment Library
Stars: ✭ 287 (-26.6%)
Mutual labels:  fragment
EasyAbout
A fully material-designed about fragment for your application.
Stars: ✭ 47 (-87.98%)
Mutual labels:  fragment

LazyFragment Build Status

类似案例:

微信 网易新闻

解决问题 1:

在多个Fragment需要加载的时候, 启动速度往往会变慢.
分析会发现并非所有的Fragment都需要第一时间将数据填充完毕.
因为它们都还没有被用户所"看见".
所以我们要达到的效果是Fragment被显示后才加载数据(lazy load).
LazyFragment由此诞生....鼓掌~~~~~~~~~~

例:
Toolbar + ViewPager + Fragment

github

解决问题 2:

ViewPager + PagerAdapter需要刷新所有子Fragment的场景.
不要new 新的 PagerAdapter 而采取reset数据的方式.
所以要求Fragment重新走initData方法.
具体参见代码示例 
**搜索关键词 setForceLoad / refreshAllFragment / refreshData 即可找到关键代码~**

github  

使用说明:

  • extends BaseFragment
    其他生命周期的方法需要重写 就自己overwrite

三个方法重点说明:

  • initViews();
    抽象方法
    与 onCreateView 类似.
    initViews 是只要 Fragment 被创建就会执行的方法.
    也就是说如果我们不想用 LazyLoad 模式
    则把所有的初始化 和 加载数据方法都写在 initViews 即可.

  • initData();
    抽象方法
    若将代码写在initData中, 则是在Fragment真正显示出来后才会去Load(懒加载).

  • setForceLoad();
    忽略isFirstLoad的值,强制刷新数据,前提是Visible & Prepared.
    未Visible & Prepared的页面需要注意在RefreshData的时候视图为空的问题, 具体请参见实例代码
    搜索关键词
    setForceLoad / refreshAllFragment / refreshData 即可找到关键代码

注意事项(一定要看完):


有个FragmentTransaction的坑,在BaseFragment文件注释中有说明(注2部分)
/**
 * 注2:
 * 如果是通过FragmentTransaction的show和hide的方法来控制显示,调用的是onHiddenChanged.
 * 针对初始就show的Fragment 为了触发onHiddenChanged事件 达到lazy效果 
 * 需要先hide再show
 * 需要先hide再show
 * 需要先hide再show
 * eg:
 * transaction.hide(aFragment);
 * transaction.show(aFragment);
 */

链接

1.https://github.com/xmagicj/LazyFragment

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].