0

I am using Bottom Navigation Layout to show 5 fragments but the problem is after every onResume is called each fragment start lagging more and more.

This is my main activity with contain bottom navigation

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;

on each method i do

 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;
    }

and oneach fragment onresume calling 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();
    }

and rendering data

    @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);
        }
    }

when ever i go to background and come back to application every fragment start lagging on scrolling

Rachit Goyal
  • 151
  • 1
  • 6

1 Answers1

0

I was searching solution for this issue i have got this link Android Facebook SDK lowers app performance me also using facebook sdk for login purpose so making autologging value to false my issue resolved.

Rachit Goyal
  • 151
  • 1
  • 6