1

I'm creating an app which has only one Activity, a FragmentActivity who works like a "ViewPager dashboard" with some option pages (ViewPager Fragments) and for each page I've some options buttons.
This option buttons toggle a SlideUp Menu (SM) that changes its layout (submenu fragment) according with the button pressed.

This submenus are created inside their parent fragment menu method (which calls createFragments()):

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)



The parent menu has 3 helper methods to manage it submenu fragments:

private void createFragments() {
    ...
    mSubMenuFragmentMap.put(..., new SubMenuFragment(...)); 
    for (Map.Entry<String, BaseSubMenuFragment> frag : mSubMenuFragmentMap.entrySet()) {
        getFragmentManager().beginTransaction().add(mMenuSlideUp.getId(), frag.getValue(), frag.getKey()).commit();
    }
    hideFragments();
}


private void hideFragments() {
    for (Fragment frag : mSubMenuFragmentMap.values()) {
        getFragmentManager().beginTransaction().hide(frag).commit();
    }
}

private void changeSubMenuFragment(int elementResId) {
    if (!isVisible) {
        mCurrentSubMenuFragment = mSubMenuFragmentMap.get(Integer.toString(elementResId));

        hideFragments();
        if (mCurrentSubMenuFragment != null) {
            getFragmentManager().beginTransaction().show(mCurrentSubMenuFragment).commit();
        }
    }
    toggleSlideMenu();
}


The changeSubMenuFragment it's called by the options buttons inside the ViewPager menu page.

The SubMenuFragment extends BaseSubMenuFragment that has 2 abstract methods:

protected void onLayoutSetup(ViewGroup rootView) 

and

protected void onLayoutRefresh(boolean slideMenuIsUp)


The onLayoutSetup it's called when the submenu slides up for the first time, the onLayoutRefresh it's called every time the submenu is toggled (slide up or down).

Everything works as expected but I'm experiencing a little delay when the submenu's layout it's created and displayed (onLayoutSetup), but only for the first time. This delay it's bigger if my submenu has ListViews (when setting the BaseAdapter) or ScrollViews. What happen is the submenu slides up, I wait for about 2 seconds (it's an example because it depends on the submenu layout complexity) and the layout shows up (this submenu from now on will not experience delays when showing).

What I'm doing wrong here?
Thanks for your time

GuilhE
  • 11,591
  • 16
  • 75
  • 116

0 Answers0