This commit is contained in:
wangcongtao
2020-01-10 11:04:08 +08:00
parent 8d1c690b09
commit 8decd42f67
4 changed files with 26 additions and 0 deletions

View File

@@ -127,4 +127,19 @@ public class FragmentStack {
public void setFragmentStackTransactionListener( FragmentStackTransactionListener fragmentStackTransactionListener ) {
this.mFragmentStackTransactionListener = fragmentStackTransactionListener;
}
public void clearAll() {
if ( mFragmentStack.isEmpty() ) {
return;
}
mFragmentTransaction = mFragmentManager.beginTransaction();
for ( FragmentDescriptor descriptor : mFragmentStack ) {
mFragmentTransaction.remove( descriptor.getFragment() );
}
mFragmentTransaction.commitAllowingStateLoss();
mCurrentFragment = null;
if ( getFragmentStackTransactionListener() != null ) {
getFragmentStackTransactionListener().onTransaction();
}
}
}

View File

@@ -26,6 +26,11 @@ public class MogoFragmentManager implements IMogoFragmentManager {
FragmentStack.getInstance().pop();
}
@Override
public void clearAll() {
FragmentStack.getInstance().clearAll();
}
@Override
public void init( Context context ) {

View File

@@ -91,6 +91,7 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener {
rv_search_result.adapter = mAdapter
tv_navi_navi.setOnClickListener {
SearchServiceHolder.fragmentManager.clearAll()
SearchServiceHolder.getNavi(activity!!)
.startNavi(false)
}

View File

@@ -23,4 +23,9 @@ public interface IMogoFragmentManager extends IProvider {
* 将当前 fragment 出栈
*/
void pop();
/**
* 退出栈中所有fragment
*/
void clearAll();
}