Search in sources :

Example 1 with StoryFragment

use of net.iGap.story.liststories.StoryFragment in project iGap-Android by KianIranian-STDG.

the class BottomNavigationFragment method loadFragment.

private void loadFragment(int position) {
    currentTab = position;
    hideKeyboard();
    FragmentManager fragmentManager = getChildFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    Fragment fragment;
    switch(position) {
        case STORY_FRAGMENT:
            HelperTracker.sendTracker(HelperTracker.TRACKER_MOMENTS_TAB);
            fragment = fragmentManager.findFragmentByTag(StoryFragment.class.getName());
            if (fragment == null) {
                fragment = new StoryFragment();
                fragmentTransaction.addToBackStack(fragment.getClass().getName());
            }
            replaceFragment(fragmentTransaction, fragment, fragment.getClass().getName());
            break;
        case CALL_FRAGMENT:
            fragment = fragmentManager.findFragmentByTag(FragmentCall.class.getName());
            if (fragment == null) {
                fragment = FragmentCall.newInstance(true);
                fragmentTransaction.addToBackStack(fragment.getClass().getName());
            }
            replaceFragment(fragmentTransaction, fragment, fragment.getClass().getName());
            break;
        case CHAT_FRAGMENT:
            fragment = fragmentManager.findFragmentByTag(MainFragment.class.getName());
            if (fragment == null) {
                fragment = MainFragment.newInstance();
                fragmentTransaction.addToBackStack(fragment.getClass().getName());
            }
            replaceFragment(fragmentTransaction, fragment, fragment.getClass().getName());
            break;
        case DISCOVERY_FRAGMENT:
            fragment = fragmentManager.findFragmentByTag(DiscoveryFragment.class.getName());
            if (fragment == null) {
                fragment = DiscoveryFragment.newInstance(0);
                fragmentTransaction.addToBackStack(fragment.getClass().getName());
            }
            if (crawlerStruct != null && !crawlerStruct.isWorkDone()) {
                ((DiscoveryFragment) fragment).setNeedToCrawl(true);
            }
            replaceFragment(fragmentTransaction, fragment, fragment.getClass().getName());
            break;
        case PROFILE_FRAGMENT:
            fragment = fragmentManager.findFragmentByTag(FragmentUserProfile.class.getName());
            if (fragment == null) {
                fragment = new FragmentUserProfile();
                fragmentTransaction.addToBackStack(fragment.getClass().getName());
            }
            replaceFragment(fragmentTransaction, fragment, fragment.getClass().getName());
            break;
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentTransaction(androidx.fragment.app.FragmentTransaction) StoryFragment(net.iGap.story.liststories.StoryFragment) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) PopularMoreChannelFragment(net.iGap.fragments.populaChannel.PopularMoreChannelFragment) PopularChannelHomeFragment(net.iGap.fragments.populaChannel.PopularChannelHomeFragment) StoryFragment(net.iGap.story.liststories.StoryFragment) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment)

Aggregations

Fragment (androidx.fragment.app.Fragment)1 FragmentManager (androidx.fragment.app.FragmentManager)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 DiscoveryFragment (net.iGap.fragments.discovery.DiscoveryFragment)1 PopularChannelHomeFragment (net.iGap.fragments.populaChannel.PopularChannelHomeFragment)1 PopularMoreChannelFragment (net.iGap.fragments.populaChannel.PopularMoreChannelFragment)1 HelperFragment (net.iGap.helper.HelperFragment)1 StoryFragment (net.iGap.story.liststories.StoryFragment)1