Example usage for android.app FragmentTransaction hide

List of usage examples for android.app FragmentTransaction hide

Introduction

In this page you can find the example usage for android.app FragmentTransaction hide.

Prototype

public abstract FragmentTransaction hide(Fragment fragment);

Source Link

Document

Hides an existing fragment.

Usage

From source file:com.android.dialer.DialtactsFragment.java

private void showSearchFragment() {
    final FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
    getActivity().getActionBar().hide();
    mSearchViewShow = true;/*from   ww  w.j ava  2s .  c o  m*/
    mDialpadFragment.showSearchView();
    if (mCalllogList != null) {
        //Log.e(TAG,"SHOWSearchFragment");
        transaction.hide(mCalllogList);
    }
    if (getCallLogFragment() != null) {
        transaction.hide(getCallLogFragment());
    }
    transaction.commitAllowingStateLoss();
}

From source file:org.opendatakit.tables.activities.TableDisplayActivity.java

/**
 * Hide every fragment except that specified by fragmentToKeepVisible.
 * //from   w  w  w  .j  ava2s.com
 * @param fragmentToKeepVisible
 * @param fragmentTransaction
 *            the transaction on which the calls to hide the fragments is to
 *            be performed
 */
private void hideAllOtherViewFragments(ViewFragmentType fragmentToKeepVisible,
        FragmentTransaction fragmentTransaction) {
    FragmentManager fragmentManager = this.getFragmentManager();
    // First acquire all the possible fragments.
    Fragment spreadsheet = fragmentManager.findFragmentByTag(Constants.FragmentTags.SPREADSHEET);
    Fragment list = fragmentManager.findFragmentByTag(Constants.FragmentTags.LIST);
    Fragment graphManager = fragmentManager.findFragmentByTag(Constants.FragmentTags.GRAPH_MANAGER);
    Fragment mapList = fragmentManager.findFragmentByTag(Constants.FragmentTags.MAP_LIST);
    Fragment mapInner = fragmentManager.findFragmentByTag(Constants.FragmentTags.MAP_INNER_MAP);
    Fragment detailFragment = fragmentManager.findFragmentByTag(Constants.FragmentTags.DETAIL_FRAGMENT);
    Fragment graphViewFragment = fragmentManager.findFragmentByTag(Constants.FragmentTags.GRAPH_VIEW);
    if (fragmentToKeepVisible != ViewFragmentType.SPREADSHEET && spreadsheet != null) {
        fragmentTransaction.hide(spreadsheet);
    }
    if (fragmentToKeepVisible != ViewFragmentType.LIST && list != null) {
        fragmentTransaction.hide(list);
    }

    if (fragmentToKeepVisible != ViewFragmentType.DETAIL && detailFragment != null) {
        fragmentTransaction.hide(detailFragment);
    }

    if (fragmentToKeepVisible != ViewFragmentType.MAP) {
        if (mapList != null) {
            fragmentTransaction.hide(mapList);
        }
        if (mapInner != null) {
            fragmentTransaction.hide(mapInner);
        }
    }
}

From source file:com.android.settings.HWSettings.java

private void createFragments() {
    DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);

    this.mViewPager = ((ViewPager) findViewById(R.id.tab_pager));
    this.mPagerAdapter = new SettingsPagerAdapter();
    this.mViewPager.setAdapter(this.mPagerAdapter);
    SettingsPageChangeListener localSettingsPageChangeListener = new SettingsPageChangeListener();
    this.mViewPager.setOnPageChangeListener(localSettingsPageChangeListener);
    this.mFragmentManager = getFragmentManager();
    FragmentTransaction localFragmentTransaction = this.mFragmentManager.beginTransaction();
    Fragment localFragment1 = this.mFragmentManager
            .findFragmentByTag("com.android.settings.HWAllSettingsFragment");
    if (localFragment1 != null)
        localFragmentTransaction.remove(localFragment1);
    Fragment localFragment2 = this.mFragmentManager
            .findFragmentByTag("com.android.settings.HWGeneralSettingsFragment");
    if (localFragment2 != null)
        localFragmentTransaction.remove(localFragment2);
    Log.d("dingjingliang", "createFragments: curTabIndex" + curTabIndex);
    this.mGeneralSettingsFragment = new HWGeneralSettingsFragment(mAuthenticatorHelper, dpm);
    localFragmentTransaction.add(R.id.tab_pager, this.mGeneralSettingsFragment,
            "com.android.settings.HWGeneralSettingsFragment");
    localFragmentTransaction.hide(this.mGeneralSettingsFragment);
    this.mAllSettingsFragment = new HWAllSettingsFragment(mAuthenticatorHelper, dpm);
    localFragmentTransaction.add(R.id.tab_pager, this.mAllSettingsFragment,
            "com.android.settings.HWAllSettingsFragment");
    localFragmentTransaction.hide(this.mAllSettingsFragment);
    localFragmentTransaction.commitAllowingStateLoss();
    this.mFragmentManager.executePendingTransactions();
}

From source file:org.appspot.apprtc.CallActivity.java

private void toggleCallControlFragmentVisibility() {

    updateVideoView();/*  w  w  w.  j a v a  2 s  . com*/

    if (!iceConnected || !callFragment.isAdded()) {
        return;
    }
    // Show/hide call control fragment
    callControlFragmentVisible = !callControlFragmentVisible;
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    if (callControlFragmentVisible) {
        ft.show(callFragment);
        ft.show(hudFragment);
    } else {
        ft.hide(callFragment);
        ft.hide(hudFragment);
    }
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    ft.commit();
}

From source file:com.android.contacts.activities.PeopleActivity.java

private void createViewsAndFragments(Bundle savedState) {
    // Disable the ActionBar so that we can use a Toolbar. This needs to be called before
    // setContentView().
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.people_activity);

    final FragmentManager fragmentManager = getFragmentManager();

    // Hide all tabs (the current tab will later be reshown once a tab is selected)
    final FragmentTransaction transaction = fragmentManager.beginTransaction();

    mTabTitles = new String[TabState.COUNT];
    mTabTitles[TabState.FAVORITES] = getString(R.string.favorites_tab_label);
    mTabTitles[TabState.ALL] = getString(R.string.all_contacts_tab_label);
    mTabPager = getView(R.id.tab_pager);
    mTabPagerAdapter = new TabPagerAdapter();
    mTabPager.setAdapter(mTabPagerAdapter);
    mTabPager.setOnPageChangeListener(mTabPagerListener);

    // Configure toolbar and toolbar tabs. If in landscape mode, we  configure tabs differntly.
    final Toolbar toolbar = getView(R.id.toolbar);
    setActionBar(toolbar);//from www  .  j  a v  a2 s  .  c o m
    final ViewPagerTabs portraitViewPagerTabs = (ViewPagerTabs) findViewById(R.id.lists_pager_header);
    ViewPagerTabs landscapeViewPagerTabs = null;
    if (portraitViewPagerTabs == null) {
        landscapeViewPagerTabs = (ViewPagerTabs) getLayoutInflater()
                .inflate(R.layout.people_activity_tabs_lands, toolbar, /* attachToRoot = */ false);
        mViewPagerTabs = landscapeViewPagerTabs;
    } else {
        mViewPagerTabs = portraitViewPagerTabs;
    }
    mViewPagerTabs.setViewPager(mTabPager);

    final String FAVORITE_TAG = "tab-pager-favorite";
    final String ALL_TAG = "tab-pager-all";

    // Create the fragments and add as children of the view pager.
    // The pager adapter will only change the visibility; it'll never create/destroy
    // fragments.
    // However, if it's after screen rotation, the fragments have been re-created by
    // the fragment manager, so first see if there're already the target fragments
    // existing.
    mFavoritesFragment = (ContactTileListFragment) fragmentManager.findFragmentByTag(FAVORITE_TAG);
    mAllFragment = (MultiSelectContactsListFragment) fragmentManager.findFragmentByTag(ALL_TAG);

    if (mFavoritesFragment == null) {
        mFavoritesFragment = new ContactTileListFragment();
        mAllFragment = new MultiSelectContactsListFragment();

        transaction.add(R.id.tab_pager, mFavoritesFragment, FAVORITE_TAG);
        transaction.add(R.id.tab_pager, mAllFragment, ALL_TAG);
    }

    mFavoritesFragment.setListener(mFavoritesFragmentListener);

    mAllFragment.setOnContactListActionListener(new ContactBrowserActionListener());
    mAllFragment.setCheckBoxListListener(new CheckBoxListListener());

    // Hide all fragments for now.  We adjust visibility when we get onSelectedTabChanged()
    // from ActionBarAdapter.
    transaction.hide(mFavoritesFragment);
    transaction.hide(mAllFragment);

    transaction.commitAllowingStateLoss();
    fragmentManager.executePendingTransactions();

    // Setting Properties after fragment is created
    mFavoritesFragment.setDisplayType(DisplayType.STREQUENT);

    mActionBarAdapter = new ActionBarAdapter(this, this, getActionBar(), portraitViewPagerTabs,
            landscapeViewPagerTabs, toolbar);
    mActionBarAdapter.initialize(savedState, mRequest);

    // Add shadow under toolbar
    ViewUtil.addRectangularOutlineProvider(findViewById(R.id.toolbar_parent), getResources());

    // Configure floating action button
    mFloatingActionButtonContainer = findViewById(R.id.floating_action_button_container);
    final ImageButton floatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
    floatingActionButton.setOnClickListener(this);
    mFloatingActionButtonController = new FloatingActionButtonController(this, mFloatingActionButtonContainer,
            floatingActionButton);
    initializeFabVisibility();

    invalidateOptionsMenuIfNeeded();
}

From source file:com.xplink.android.carchecklist.CarCheckListActivity.java

public void menuToggle(int motionin, int motionout, int fragment) {

    /*/*from ww  w. j a  v  a 2s  .  c  om*/
     * final Dialog settingdialog = new Dialog(CarCheckListActivity.this,
     * R.style.backgrounddialog); settingdialog.dismiss();
     */

    new Dialog(CarCheckListActivity.this, R.style.backgrounddialog).dismiss();

    headsetting.setVisibility(ImageView.VISIBLE);
    TranslateAnimation slideoutheadsetting = new TranslateAnimation(0, 0, 0, -468);
    slideoutheadsetting.setDuration(500);
    slideoutheadsetting.setFillAfter(true);
    headsetting.startAnimation(slideoutheadsetting);

    int prefer = getSharedPreferences("mysettings", MODE_PRIVATE).getInt("already", 1);
    if (prefer == 1) {
        getSharedPreferences("mysettings", MODE_PRIVATE).edit().putInt("already", 0).commit();

        FragmentTransaction ft = getFragmentManager().beginTransaction().setCustomAnimations(motionin,
                motionout);
        FragmentManager fm = getFragmentManager();
        Fragment fmTarget = fm.findFragmentById(fragment);
        ft.show(fmTarget);
        ft.commit();
    } else {
        getSharedPreferences("mysettings", MODE_PRIVATE).edit().putInt("already", 1).commit();
        FragmentTransaction ft = getFragmentManager().beginTransaction().setCustomAnimations(motionin,
                motionout);
        FragmentManager fm = getFragmentManager();
        final Fragment fmTarget = fm.findFragmentById(fragment);
        ft.hide(fmTarget);
        ft.commit();
    }
}

From source file:de.anderdonau.spacetrader.Main.java

public void changeFragment(FRAGMENTS fragment) {
    hide_keyboard(this);
    if (fragment == gameState.currentState && currentFragment != null) {
        // Sometimes this seems to be unset. Try to workaround it.
        currentFragment.gameState = gameState;
        if (currentFragment.update()) {
            return;
        }/*from  w w w. j ava  2  s  . c om*/
    }
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();

    if (fragment == FRAGMENTS.NEW_GAME || fragment == FRAGMENTS.ENCOUNTER) {
        transaction.hide(mNavigationDrawerFragment);
    } else {
        transaction.show(mNavigationDrawerFragment);
    }

    Bundle args = new Bundle();
    args.putSerializable("gamestate", gameState);

    switch (fragment) {
    case AVERAGE_PRICES:
        currentFragment = new FragmentAveragePrices();
        break;
    case BANK:
        currentFragment = new FragmentBank();
        break;
    case BUY_CARGO:
        currentFragment = new FragmentBuyCargo();
        break;
    case BUY_EQUIPMENT:
        currentFragment = new FragmentBuyEquipment();
        break;
    case BUY_NEW_SHIP:
        currentFragment = new FragmentBuyNewShip();
        break;
    case COMMANDER_STATUS:
        currentFragment = new FragmentCommanderStatus();
        break;
    case DUMP:
        currentFragment = new FragmentDumpCargo();
        break;
    case ENCOUNTER:
        currentFragment = new FragmentEncounter();
        break;
    case GALACTIC_CHART:
        currentFragment = new FragmentGalacticChart();
        break;
    case NEW_GAME:
        currentFragment = new FragmentStartNewGame();
        break;
    case OPTIONS:
        currentFragment = new FragmentOptions();
        break;
    case PERSONNEL_ROSTER:
        currentFragment = new FragmentPersonnelRoster();
        break;
    case PLUNDER:
        currentFragment = new FragmentPlunderCargo();
        break;
    case SELL_CARGO:
        currentFragment = new FragmentSellCargo();
        break;
    case SELL_EQUIPMENT:
        currentFragment = new FragmentSellEquipment();
        break;
    case SHIPYARD:
        currentFragment = new FragmentShipyard();
        break;
    case SHIP_INFO:
        currentFragment = new FragmentShipInfo();
        break;
    case SHORTCUTS:
        currentFragment = new FragmentShortcuts();
        break;
    case SHORT_RANGE_CHART:
        currentFragment = new FragmentShortRangeChart();
        break;
    case SYSTEM_INFORMATION:
        currentFragment = new FragmentSystemInformation();
        break;
    case VERY_RARE_CHEAT:
        currentFragment = new FragmentVeryRare();
        break;
    case WARP_SYSTEM_INFORMATION:
        currentFragment = new FragmentWarpSystemInformation();
        break;
    default:
        return;
    }

    currentFragment.setArguments(args);
    transaction.replace(R.id.container, currentFragment);
    transaction.commit();
    gameState.currentState = fragment;

    invalidateOptionsMenu();
}