This commit is contained in:
wangcongtao
2020-01-08 11:17:29 +08:00
parent 6b1b06e0a8
commit b0cf11bba0
2 changed files with 26 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
package com.mogo.module.main;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -23,6 +24,7 @@ import com.mogo.module.main.cards.OnPageChangeListenerAdapter;
import com.mogo.module.main.cards.OrientedViewPager;
import com.mogo.module.main.cards.VerticalStackTransformer;
import com.mogo.module.main.fragmentmanager.FragmentStack;
import com.mogo.module.main.fragmentmanager.FragmentStackTransactionListener;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.ServiceConst;
import com.mogo.service.MogoServicePaths;
@@ -84,6 +86,16 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
} );
FragmentStack.getInstance().init( this, R.id.module_main_id_search_fragment );
FragmentStack.getInstance().setFragmentStackTransactionListener( new FragmentStackTransactionListener() {
@Override
public void onTransaction() {
if ( FragmentStack.getInstance().isEmpty() ) {
// TODO: 2020-01-08 动画
} else if ( FragmentStack.getInstance().getStackSize() == 1 ) {
}
}
} );
}
@Override

View File

@@ -87,12 +87,17 @@ public class FragmentStack {
mFragmentTransaction.commitAllowingStateLoss();
mCurrentFragment = null;
} else {
Fragment fragment = mFragmentStack.pop();
if ( fragment != null ) {
mFragmentTransaction.show( fragment );
mFragmentTransaction.commitAllowingStateLoss();
mFragmentStack.pop();
if ( !mFragmentStack.isEmpty() ) {
Fragment fragment = mFragmentStack.pop();
if ( fragment != null ) {
mFragmentTransaction.show( fragment );
mFragmentTransaction.commitAllowingStateLoss();
}
mCurrentFragment = fragment;
} else {
mCurrentFragment = null;
}
mCurrentFragment = fragment;
}
if ( getFragmentStackTransactionListener() != null ) {
@@ -104,6 +109,10 @@ public class FragmentStack {
return mFragmentStack.isEmpty();
}
public int getStackSize() {
return mFragmentStack.size();
}
public FragmentStackTransactionListener getFragmentStackTransactionListener() {
return mFragmentStackTransactionListener;
}