Search in sources :

Example 1 with DiscoveryFragment

use of net.iGap.fragments.discovery.DiscoveryFragment in project iGap-Android by KianIranian-STDG.

the class BaseViewHolder method actionPage.

private static void actionPage(String value, FragmentActivity activity, boolean haveNext) {
    try {
        // this is because in some times not set correct value in server when change or add new item
        DiscoveryFragment discoveryFragment = DiscoveryFragment.newInstance(Integer.valueOf(value));
        discoveryFragment.setNeedToCrawl(haveNext);
        new HelperFragment(activity.getSupportFragmentManager(), discoveryFragment).setReplace(false).load(false);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : HelperFragment(net.iGap.helper.HelperFragment) JSONException(org.json.JSONException) IOException(java.io.IOException) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment)

Example 2 with DiscoveryFragment

use of net.iGap.fragments.discovery.DiscoveryFragment in project iGap-Android by KianIranian-STDG.

the class BottomNavigationFragment method setCrawlerMap.

private void setCrawlerMap(int position, String[] uri) {
    try {
        if (uri != null && uri.length > 0) {
            if (!uri[0].equals(DEEP_LINK_DISCOVERY) && position == DISCOVERY_FRAGMENT) {
                List<Integer> pages = new ArrayList<>();
                for (String s : uri) {
                    pages.add(Integer.valueOf(s));
                }
                this.crawlerStruct = new DiscoveryFragment.CrawlerStruct(0, pages);
            }
        }
    } catch (Exception e) {
        HelperError.showSnackMessage(getResources().getString(R.string.link_not_valid), false);
    }
    if (position == bottomNavigation.getCurrentTab()) {
        if (bottomNavigation.getSelectedItemPosition() == DISCOVERY_FRAGMENT) {
            if (getActivity() != null && getActivity() instanceof ActivityMain)
                ((ActivityMain) getActivity()).removeAllFragmentFromMain();
            if (getActivity() != null) {
                DiscoveryFragment discoveryFragment = (DiscoveryFragment) getChildFragmentManager().findFragmentByTag(DiscoveryFragment.class.getName());
                if (discoveryFragment != null) {
                    discoveryFragment.setNeedToCrawl(true);
                    discoveryFragment.discoveryCrawler(getActivity());
                }
            }
        }
    } else {
        switch(position) {
            case STORY_FRAGMENT:
                bottomNavigation.setCurrentItem(STORY_FRAGMENT);
                break;
            case CALL_FRAGMENT:
                bottomNavigation.setCurrentItem(CALL_FRAGMENT);
                break;
            case CHAT_FRAGMENT:
                bottomNavigation.setCurrentItem(CHAT_FRAGMENT);
                break;
            case DISCOVERY_FRAGMENT:
                DiscoveryFragment discoveryFragment = (DiscoveryFragment) getChildFragmentManager().findFragmentByTag(DiscoveryFragment.class.getName());
                if (discoveryFragment != null)
                    discoveryFragment.setNeedToReload(true);
                bottomNavigation.setCurrentItem(DISCOVERY_FRAGMENT);
                break;
            case POPULAR_CHANNEL_FRAGMENT:
                if (uri != null)
                    if (uri.length > 1) {
                        PopularMoreChannelFragment popularMoreChannelFragment = new PopularMoreChannelFragment();
                        Bundle bundle = new Bundle();
                        bundle.putString("id", uri[1]);
                        popularMoreChannelFragment.setArguments(bundle);
                        new HelperFragment(getFragmentManager(), popularMoreChannelFragment).setReplace(false).load();
                    } else {
                        new HelperFragment(getFragmentManager(), new PopularChannelHomeFragment()).setReplace(false).load();
                    }
                break;
            case NEWS_FRAGMENT:
                if (uri != null) {
                    NewsMainFrag frag = new NewsMainFrag();
                    switch(uri.length) {
                        case 2:
                            frag.setSpecificGroupID(uri[1]);
                            break;
                        case 3:
                            frag.setSpecificNewsID(uri[2]);
                            break;
                        default:
                            break;
                    }
                    new HelperFragment(getFragmentManager(), frag).setReplace(false).load(false);
                }
                break;
            case PROFILE_FRAGMENT:
                bottomNavigation.setCurrentItem(PROFILE_FRAGMENT);
                break;
        }
    }
}
Also used : PopularChannelHomeFragment(net.iGap.fragments.populaChannel.PopularChannelHomeFragment) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) HelperString(net.iGap.helper.HelperString) NewsMainFrag(net.iGap.fragments.news.NewsMainFrag) ActivityMain(net.iGap.activities.ActivityMain) PopularMoreChannelFragment(net.iGap.fragments.populaChannel.PopularMoreChannelFragment) HelperFragment(net.iGap.helper.HelperFragment) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment)

Example 3 with DiscoveryFragment

use of net.iGap.fragments.discovery.DiscoveryFragment 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

DiscoveryFragment (net.iGap.fragments.discovery.DiscoveryFragment)3 HelperFragment (net.iGap.helper.HelperFragment)3 PopularChannelHomeFragment (net.iGap.fragments.populaChannel.PopularChannelHomeFragment)2 PopularMoreChannelFragment (net.iGap.fragments.populaChannel.PopularMoreChannelFragment)2 Bundle (android.os.Bundle)1 Fragment (androidx.fragment.app.Fragment)1 FragmentManager (androidx.fragment.app.FragmentManager)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ActivityMain (net.iGap.activities.ActivityMain)1 NewsMainFrag (net.iGap.fragments.news.NewsMainFrag)1 HelperString (net.iGap.helper.HelperString)1 StoryFragment (net.iGap.story.liststories.StoryFragment)1 JSONException (org.json.JSONException)1