Skip to content

Commit 444ff24

Browse files
committed
see 02/14 log
1 parent dfcdd03 commit 444ff24

File tree

7 files changed

+256
-116
lines changed

7 files changed

+256
-116
lines changed

README-CN.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,14 @@ getFileExtension : 根据全路径获取文件拓展名
214214
```
215215
addFragment : 新增fragment
216216
removeFragment : 移除fragment
217+
removeToFragment : 移除到指定fragment
218+
removeFragments : 移除同级别fragment
219+
removeAllFragments : 移除所有fragment
217220
replaceFragment : 替换fragment
218221
popFragment : 出栈fragment
219222
popToFragment : 出栈到指定fragment
223+
popFragments : 出栈同级别fragment
224+
popAllFragments : 出栈所有fragment
220225
popAddFragment : 先出栈后新增fragment
221226
hideFragment : 隐藏fragment
222227
showFragment : 显示fragment
@@ -225,11 +230,13 @@ getLastAddFragment : 获取最后加入的fragment
225230
getLastAddFragmentInStack: 获取栈中最后加入的fragment
226231
getTopShowFragment : 获取顶层可见fragment
227232
getTopShowFragmentInStack: 获取栈中顶层可见fragment
228-
findFragment : 查找fragment
229233
getPreFragment : 获取目标fragment的前一个fragment
230-
getFragments : 获取同级别的fragment
234+
getFragments : 获取同级别fragment
235+
getFragmentsInStack : 获取栈中同级别fragment
231236
getAllFragments : 获取所有fragment
232237
getAllFragmentsInStack : 获取栈中所有fragment
238+
findFragment : 查找fragment
239+
dispatchBackPress : 处理fragment回退键
233240
setBackgroundColor : 设置背景色
234241
setBackgroundResource : 设置背景资源
235242
setBackground : 设置背景

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,14 @@ getFileExtension
214214
```
215215
addFragment
216216
removeFragment
217+
removeToFragment
218+
removeFragments
219+
removeAllFragments
217220
replaceFragment
218221
popFragment
219222
popToFragment
223+
popFragments
224+
popAllFragments
220225
popAddFragment
221226
hideFragment
222227
showFragment
@@ -225,11 +230,13 @@ getLastAddFragment
225230
getLastAddFragmentInStack
226231
getTopShowFragment
227232
getTopShowFragmentInStack
228-
findFragment
229233
getPreFragment
230234
getFragments
235+
getFragmentsInStack
231236
getAllFragments
232237
getAllFragmentsInStack
238+
findFragment
239+
dispatchBackPress
233240
setBackgroundColor
234241
setBackgroundResource
235242
setBackground

app/src/main/java/com/blankj/androidutilcode/fragment/Demo0Fragment.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* </pre>
2828
*/
2929
public class Demo0Fragment extends Fragment
30-
implements View.OnClickListener,FragmentUtils.OnBackClickListener {
30+
implements View.OnClickListener, FragmentUtils.OnBackClickListener {
3131

3232
private Fragment fragment1;
3333

@@ -75,14 +75,16 @@ public void onClick(View view) {
7575
tvAboutFragment.setText("");
7676
switch (view.getId()) {
7777
case R.id.btn_show_about_fragment:
78-
tvAboutFragment.setText("---all fragments---\n"
78+
tvAboutFragment.setText("lastAdd: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName()
79+
+ "\nlastAddInStack: " + (FragmentUtils.getLastAddFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getLastAddFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
80+
+ "\ntopShow: " + FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName()
81+
+ "\ntopShowInStack: " + (FragmentUtils.getTopShowFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getTopShowFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
82+
+ "\n---all of fragments---\n"
7983
+ FragmentUtils.getAllFragments(getFragmentManager()).toString()
80-
+ "\n-------------------\n\n"
84+
+ "\n----------------------\n\n"
8185
+ "---stack top---\n"
8286
+ FragmentUtils.getAllFragmentsInStack(getFragmentManager()).toString()
8387
+ "\n---stack bottom---\n\n"
84-
+ "\ntopFragment: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName()
85-
+ "\ntopShowFragment: " + FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName()
8688
);
8789
break;
8890
case R.id.btn_add_hide:
@@ -117,7 +119,7 @@ public void onClick(View view) {
117119

118120
@Override
119121
public boolean onBackClick() {
120-
FragmentUtils.popToFragment(getFragmentManager(), Demo1Fragment.class, true);
122+
// FragmentUtils.popToFragment(getFragmentManager(), Demo1Fragment.class, true);
121123
return false;
122124
}
123125
}

app/src/main/java/com/blankj/androidutilcode/fragment/Demo1Fragment.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,16 @@ public void onClick(View view) {
6262
tvAboutFragment.setText("");
6363
switch (view.getId()) {
6464
case R.id.btn_show_about_fragment:
65-
tvAboutFragment.setText("---all fragments---\n"
65+
tvAboutFragment.setText("lastAdd: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName()
66+
+ "\nlastAddInStack: " + (FragmentUtils.getLastAddFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getLastAddFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
67+
+ "\ntopShow: " + FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName()
68+
+ "\ntopShowInStack: " + (FragmentUtils.getTopShowFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getTopShowFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
69+
+ "\n---all of fragments---\n"
6670
+ FragmentUtils.getAllFragments(getFragmentManager()).toString()
67-
+ "\n-------------------\n\n"
71+
+ "\n----------------------\n\n"
6872
+ "---stack top---\n"
6973
+ FragmentUtils.getAllFragmentsInStack(getFragmentManager()).toString()
7074
+ "\n---stack bottom---\n\n"
71-
+ "\ntopFragment: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName()
72-
+ "\ntopShowFragment: " + FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName()
7375
);
7476
break;
7577
case R.id.btn_hide_show:

app/src/main/java/com/blankj/androidutilcode/fragment/Demo2Fragment.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,16 @@ public void onClick(View view) {
6262
tvAboutFragment.setText("");
6363
switch (view.getId()) {
6464
case R.id.btn_show_about_fragment:
65-
tvAboutFragment.setText("---all fragments---\n"
65+
tvAboutFragment.setText("lastAdd: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName()
66+
+ "\nlastAddInStack: " + (FragmentUtils.getLastAddFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getLastAddFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
67+
+ "\ntopShow: " + FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName()
68+
+ "\ntopShowInStack: " + (FragmentUtils.getTopShowFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getTopShowFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
69+
+ "\n---all of fragments---\n"
6670
+ FragmentUtils.getAllFragments(getFragmentManager()).toString()
67-
+ "\n-------------------\n\n"
71+
+ "\n----------------------\n\n"
6872
+ "---stack top---\n"
6973
+ FragmentUtils.getAllFragmentsInStack(getFragmentManager()).toString()
7074
+ "\n---stack bottom---\n\n"
71-
+ "\ntopFragment: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName()
72-
+ "\ntopShowFragment: " + FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName()
7375
);
7476
break;
7577
case R.id.btn_pop:

app/src/main/java/com/blankj/androidutilcode/fragment/Demo3Fragment.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,16 @@ public void onClick(View view) {
7474
tvAboutFragment.setText("");
7575
switch (view.getId()) {
7676
case R.id.btn_show_about_fragment:
77-
tvAboutFragment.setText("---stack top---\n"
77+
tvAboutFragment.setText("lastAdd: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName()
78+
+ "\nlastAddInStack: " + (FragmentUtils.getLastAddFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getLastAddFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
79+
+ "\ntopShow: " + FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName()
80+
+ "\ntopShowInStack: " + (FragmentUtils.getTopShowFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getTopShowFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
81+
+ "\n---all of fragments---\n"
7882
+ FragmentUtils.getAllFragments(getFragmentManager()).toString()
79-
+ "\n---stack bottom---\n"
80-
+ "\ntopFragment: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName()
81-
+ "\ntopShowFragment: " + FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName()
83+
+ "\n----------------------\n\n"
84+
+ "---stack top---\n"
85+
+ FragmentUtils.getAllFragmentsInStack(getFragmentManager()).toString()
86+
+ "\n---stack bottom---\n\n"
8287
);
8388
break;
8489
case R.id.btn_add_show:

0 commit comments

Comments
 (0)