Source:
public void initFragments() { @IdRes int checkedId = -1; final FragmentManager fragmentManager = getChildFragmentManager(); if (environment.getConfig().getDiscoveryConfig().getProgramDiscoveryConfig() != null && environment.getConfig().getDiscoveryConfig().getProgramDiscoveryConfig().isDiscoveryEnabled(environment)) { programDiscoveryFragment = new WebViewDiscoverProgramsFragment(); final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.fl_programs, programDiscoveryFragment, "fragment_programs"); fragmentTransaction.commit(); checkedId = R.id.option_programs; } else { hideTabsBar(); } if (environment.getConfig().getDiscoveryConfig().getCourseDiscoveryConfig() != null && environment.getConfig().getDiscoveryConfig().getCourseDiscoveryConfig().isDiscoveryEnabled()) { if (environment.getConfig().getDiscoveryConfig().getCourseDiscoveryConfig().isWebviewDiscoveryEnabled()) { courseDiscoveryFragment = new WebViewDiscoverCoursesFragment(); courseDiscoveryFragment.setArguments(getArguments()); } else { courseDiscoveryFragment = new NativeFindCoursesFragment(); } final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.fl_courses, courseDiscoveryFragment, "fragment_courses"); fragmentTransaction.commit(); checkedId = R.id.option_courses; } else { hideTabsBar(); } if (checkedId != -1) { onFragmentSelected(checkedId, false); binding.options.check(checkedId); } }

Target:
public void initFragments() { @IdRes int checkedId = -1; if (environment.getConfig().getDiscoveryConfig().getProgramDiscoveryConfig() != null && environment.getConfig().getDiscoveryConfig().getProgramDiscoveryConfig().isDiscoveryEnabled(environment)) { programDiscoveryFragment = getChildFragmentManager().findFragmentByTag("fragment_programs"); if (programDiscoveryFragment == null) { programDiscoveryFragment = new WebViewDiscoverProgramsFragment(); commitFragmentTransaction(R.id.fl_programs, programDiscoveryFragment, "fragment_programs"); } checkedId = R.id.option_programs; } else { hideTabsBar(); } if (environment.getConfig().getDiscoveryConfig().getCourseDiscoveryConfig() != null && environment.getConfig().getDiscoveryConfig().getCourseDiscoveryConfig().isDiscoveryEnabled()) { if (environment.getConfig().getDiscoveryConfig().getCourseDiscoveryConfig().isWebviewDiscoveryEnabled()) { courseDiscoveryFragment = getChildFragmentManager().findFragmentByTag("fragment_courses_webview"); if (courseDiscoveryFragment == null) { courseDiscoveryFragment = new WebViewDiscoverCoursesFragment(); courseDiscoveryFragment.setArguments(getArguments()); commitFragmentTransaction(R.id.fl_courses, courseDiscoveryFragment, "fragment_courses_webview"); } } else { courseDiscoveryFragment = getChildFragmentManager().findFragmentByTag("fragment_courses_native"); if (courseDiscoveryFragment == null) { courseDiscoveryFragment = new NativeFindCoursesFragment(); commitFragmentTransaction(R.id.fl_courses, courseDiscoveryFragment, "fragment_courses_native"); } } checkedId = R.id.option_courses; } else { hideTabsBar(); } if (checkedId != -1) { onFragmentSelected(checkedId, false); binding.options.check(checkedId); } }