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();
}
}
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;
}
}
}
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;
}
}
Aggregations