Я использую Bottom Navigation Layout, чтобы показать 5 фрагментов, но проблема в том, что после того, как каждый onResume вызывается, каждый фрагмент начинает отставать все больше и больше.
Это моя основная деятельность с навигацией по нижнему содержанию
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.menu_home:
if (!selectedFragment.equalsIgnoreCase(Consts.MasterHomeFragment)) {
openMasterHomeFragment();
}
break;
case R.id.menu_wallet:
if (!isSessionActive()) {
showLoginBottomDialog();
return false;
} else {
if (!selectedFragment.equalsIgnoreCase(Consts.WalletFragment))
openWalletFragment();
}
break;
case R.id.menu_portfolio:
if (!isSessionActive()) {
showLoginBottomDialog();
return false;
} else {
if (!selectedFragment.equalsIgnoreCase(Consts.PortfolioFragment))
openPortfolioFragment();
}
break;
для каждого метода, который я делаю
public void openPortfolioFragment() {
eventTracker.track(EventTracker.HOME_PORTFOLIO_NAV_CLICKED);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
PortfolioFragment portfolioFragment = new PortfolioFragment();
transaction.replace(R.id.activity_home_main_frame, portfolioFragment);
transaction.commit();
selectedFragment = Consts.PortfolioFragment;
}
public void openProfileFragment() {
eventTracker.track(EventTracker.HOME_ACCOUNT_NAV_CLICKED);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
ProfileFragment profileFragment = new ProfileFragment();
transaction.replace(R.id.activity_home_main_frame, profileFragment);
transaction.commit();
selectedFragment = Consts.ProfileFragment;
}
, и каждый фрагмент повторяет вызов api
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_wallet, container, false);
unbinder = ButterKnife.bind(this, view);
initViewPager(view);
return view;
}
@Override
public void onResume() {
super.onResume();
loadDataFromApi();
}
и рендеринг данных
@Override
public void onDataLoaded(MasterHomeResponse response) {
if (getActivity() != null && isAdded()) {
masterHomeResponse = response;
hideRefreshing();
initPortfolio(response);
initInbox(response.getInbox());
initAssets(response);
initTutorial(response);
initFeeds(response);
showBottomMoreFloatingButton();
boolean dismissIntro = sharedPreferenceHelper.getSamplePreference().getShowCase();
showGuideView(response, dismissIntro);
}
}
когда бы я ни был go к фону и возвращению к приложению, каждый фрагмент начинает отставать при прокрутке