@@ -50,11 +50,19 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
5050 return super .dispatchTouchEvent (ev );
5151 }
5252
53+ /**
54+ * 获取默认的Fragment背景颜色
55+ * @return
56+ */
5357 @ Override
5458 public int getDefaultBackground () {
5559 return Color .WHITE ;
5660 }
5761
62+ /**
63+ * 设置全局默认动画
64+ * @param animation
65+ */
5866 @ Override
5967 public void setDefaultAnimation (FragmentAnimation animation ) {
6068 defaultAnimation = animation ;
@@ -70,11 +78,22 @@ public FragmentAnimation getDefaultAnimation() {
7078 return defaultAnimation ;
7179 }
7280
81+ /**
82+ * 在栈内查找Fragment对象,如果一个栈内存在多个同一个class的Fragment对象,则返回结果可能不准确
83+ * @param cls
84+ * @param <T>
85+ * @return
86+ */
7387 @ Override
7488 public <T extends SupportFragment > T findFragmentByClass (Class cls ) {
7589 return FragmentUtils .findFragmentByClass (getSupportFragmentManager (),cls );
7690 }
7791
92+ /**
93+ * 发送一条消息到当前所有的Fragment
94+ * @param code
95+ * @param data
96+ */
7897 @ Override
7998 public void postDataToFragments (int code , Bundle data ) {
8099 List <SupportFragment > fragmentList = new ArrayList <>();
@@ -84,92 +103,180 @@ public void postDataToFragments(int code, Bundle data) {
84103 }
85104 }
86105
106+ /**
107+ * 加载第一个Fragment
108+ * @param containerId
109+ * @param to
110+ * @param anim
111+ * @param playEnterAnim
112+ * @param addToBackStack
113+ */
87114 @ Override
88115 public void loadRootFragment (int containerId , SupportFragment to , FragmentAnimation anim , boolean playEnterAnim ,boolean addToBackStack ) {
89116 supportTransaction .loadRootFragment (getSupportFragmentManager (),containerId ,to ,anim ,playEnterAnim ,addToBackStack );
90117 }
91118
119+ /**
120+ * 加载第一个Fragment
121+ * @param containerId
122+ * @param to
123+ */
92124 @ Override
93125 public void loadRootFragment (int containerId , SupportFragment to ) {
94126 supportTransaction .loadRootFragment (getSupportFragmentManager (),containerId ,to ,getDefaultAnimation (),false ,true );
95127 }
96128
129+ /**
130+ * 加载多个Fragment
131+ * @param containerId
132+ * @param showPosition
133+ * @param fragments
134+ */
97135 @ Override
98136 public void loadMultipleRootFragments (int containerId , int showPosition , SupportFragment ... fragments ) {
99137 supportTransaction .loadMultipleRootFragments (getSupportFragmentManager (),containerId ,showPosition ,fragments );
100138 }
101139
140+ /**
141+ * 显示一个Fragment,并隐藏当前Child Fragment Manager 栈内的其它Fragment
142+ * @param show
143+ */
102144 @ Override
103145 public void showHideAllFragment (SupportFragment show ) {
104146 supportTransaction .showHideAllFragment (getSupportFragmentManager (), show );
105147 }
106148
149+ /**
150+ * 启动一个新的Fragment,栈内必须有至少1个Fragment才可以使用此方法
151+ * @param to
152+ */
107153 @ Override
108154 public void start (SupportFragment to ) {
109155 supportTransaction .start (FragmentUtils .getLastFragment (getSupportFragmentManager ()),to ,true );
110156 }
111157
158+ /**
159+ * 启动一个新的Fragment,栈内必须有至少1个Fragment才可以使用此方法
160+ * @param to
161+ * @param addToBackStack
162+ */
112163 @ Override
113164 public void start (SupportFragment to , boolean addToBackStack ) {
114165 supportTransaction .start (FragmentUtils .getLastFragment (getSupportFragmentManager ()),to ,addToBackStack );
115166 }
116167
168+ /**
169+ * 启动一个新的Fragment,栈内必须有至少1个Fragment才可以使用此方法
170+ * @param from
171+ * @param to
172+ */
117173 @ Override
118174 public void start (SupportFragment from , SupportFragment to ) {
119175 supportTransaction .start (from ,to ,true );
120176 }
121177
178+ /**
179+ * 启动一个新的Fragment,栈内必须有至少1个Fragment才可以使用此方法
180+ * @param from
181+ * @param to
182+ * @param addToBackStack
183+ */
122184 @ Override
123185 public void start (SupportFragment from , SupportFragment to , boolean addToBackStack ) {
124186 supportTransaction .start (from ,to ,addToBackStack );
125187 }
126188
189+ /**
190+ * 启动一个新的Fragment并关闭当前Fragment
191+ * @param to
192+ */
127193 @ Override
128194 public void startWithPop (SupportFragment to ) {
129195 supportTransaction .startWithPop (FragmentUtils .getLastFragment (getSupportFragmentManager ()), to );
130196 }
131197
198+ /**
199+ * 启动一个新的Fragment并关闭当前Fragment
200+ * @param from
201+ * @param to
202+ */
132203 @ Override
133204 public void startWithPop (SupportFragment from , SupportFragment to ) {
134205 supportTransaction .startWithPop (from , to );
135206 }
136207
208+ /**
209+ * 启动一个新的Fragment,并弹出栈内的Fragment到指定位置
210+ * @param to
211+ * @param cls
212+ */
137213 @ Override
138214 public void startWithPopTo (SupportFragment to , Class cls ) {
139215 supportTransaction .startWithPopTo (FragmentUtils .getLastFragment (getSupportFragmentManager ()),to ,cls ,true );
140216 }
141217
218+ /**
219+ * 启动一个新的Fragment,并弹出栈内的Fragment到指定位置
220+ * @param to
221+ * @param cls
222+ * @param includeTarget
223+ */
142224 @ Override
143225 public void startWithPopTo (SupportFragment to , Class cls , boolean includeTarget ) {
144226 supportTransaction .startWithPopTo (FragmentUtils .getLastFragment (getSupportFragmentManager ()),to ,cls ,includeTarget );
145227 }
146228
229+ /**
230+ * 启动一个新的Fragment,并弹出栈内的Fragment到指定位置
231+ * @param from
232+ * @param to
233+ * @param cls
234+ */
147235 @ Override
148236 public void startWithPopTo (SupportFragment from , SupportFragment to , Class cls ) {
149237 supportTransaction .startWithPopTo (from ,to ,cls ,true );
150238 }
151239
240+ /**
241+ * 启动一个新的Fragment,并弹出栈内的Fragment到指定位置
242+ * @param from
243+ * @param to
244+ * @param cls
245+ * @param includeTarget
246+ */
152247 @ Override
153248 public void startWithPopTo (SupportFragment from , SupportFragment to , Class cls , boolean includeTarget ) {
154249 supportTransaction .startWithPopTo (from ,to ,cls ,includeTarget );
155250 }
156251
252+ /**
253+ * 弹出栈内最后一个Fragment
254+ */
157255 @ Override
158256 public void pop () {
159257 supportTransaction .pop (getSupportFragmentManager ());
160258 }
161259
260+ /**
261+ * 弹出栈内的Fragment到指定位置
262+ * @param cls
263+ */
162264 @ Override
163265 public void popTo (Class cls ) {
164266 supportTransaction .popTo (getSupportFragmentManager (),cls ,true );
165267 }
166268
269+ /**
270+ * 弹出栈内的Fragment到指定位置
271+ * @param cls
272+ * @param includeTarget
273+ */
167274 @ Override
168275 public void popTo (Class cls , boolean includeTarget ) {
169276 supportTransaction .popTo (getSupportFragmentManager (),cls ,includeTarget );
170277 }
171278
172- public SupportTransaction getSupportTransaction () {
279+ SupportTransaction getSupportTransaction () {
173280 return supportTransaction ;
174281 }
175282}
0 commit comments