源码地址:Github,欢迎Star,Fork。java
A powerful library that manage Fragment for Android!git
为"单Activity + 多Fragment","多模块Activity + 多Fragment"架构而生,简化开发,轻松解决动画、嵌套、事务相关等问题。github

为了更好的使用和了解该库,推荐阅读下面的文章:express
Demo演示:
均为单Activity + 多Fragment,第一个为简单流式demo,第二个为仿微信交互的demo(全页面支持滑动退出),第三个为仿知乎交互的复杂嵌套demo微信
特性
一、悬浮球/摇一摇实时查看Fragment的栈视图,下降开发难度架构
二、内部队列机制 解决Fragment多点触控、事务高频次提交异常等问题app
三、增长启动模式、startForResult等类Activity方法less
四、类Android事件分发机制的Fragment BACK键机制:onBackPressedSupport()
五、提供onSupportVisible()、懒加载onLazyInitView()等生命周期方法,简化嵌套Fragment的开发过程
六、提供 Fragment转场动画 系列解决方案,动态改变更画
七、提供Activity做用域的EventBus辅助类,Fragment通讯更简单、独立(须要使用EventBusActivityScope库)
八、


如何使用
1. 项目下app的build.gradle中依赖:
// appcompat-v7包是必须的
compile 'me.yokeyword:fragmentation:1.3.6'
// 若是不想继承SupportActivity/Fragment,本身定制Support,可仅依赖:
// compile 'me.yokeyword:fragmentation-core:1.3.6'
// 若是想使用SwipeBack 滑动边缘退出Fragment/Activity功能,完整的添加规则以下:
compile 'me.yokeyword:fragmentation:1.3.6'
// swipeback基于fragmentation, 若是是自定制SupportActivity/Fragment,则参照SwipeBackActivity/Fragment实现便可
compile 'me.yokeyword:fragmentation-swipeback:1.3.6'
// Activity做用域的EventBus,更安全,可有效避免after onSavenInstanceState()异常
compile 'me.yokeyword:eventbus-activity-scope:1.1.0'
// Your EventBus's version
compile 'org.greenrobot:eventbus:{version}'
2. Activity extends SupportActivity或者 implements ISupportActivity:(实现方式可参考MySupportActivity)
// v1.0.0开始,不强制继承SupportActivity,可以使用接口+委托形式来实现本身的SupportActivity
public class MainActivity extends SupportActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(...);
// 建议在Application里初始化
Fragmentation.builder()
// 显示悬浮球 ; 其余Mode:SHAKE: 摇一摇唤出 NONE:隐藏
.stackViewMode(Fragmentation.BUBBLE)
.debug(BuildConfig.DEBUG)
... // 更多查看wiki或demo
.install();
if (findFragment(HomeFragment.class) == null) {
loadRootFragment(R.id.fl_container, HomeFragment.newInstance()); // 加载根Fragment
}
}
3. Fragment extends SupportFragment或者 implements ISupportFragment:(实现方式可参考MySupportFragment):
// v1.0.0开始,不强制继承SupportFragment,可以使用接口+委托形式来实现本身的SupportFragment
public class HomeFragment extends SupportFragment {
private void xxx() {
// 启动新的Fragment, 另有start(fragment,SINGTASK)、startForResult、startWithPop等启动方法
start(DetailFragment.newInstance(HomeBean));
// ... 其余pop, find, 设置动画等等API, 请自行查看WIKI
}
}
LICENSE
Copyright 2016 YoKey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.