List of usage examples for android.app FragmentTransaction hide
public abstract FragmentTransaction hide(Fragment fragment);
From source file:com.zte.permissioncontrol.ui.PermissionControlPageActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.permission_control_pages); mEmptyView = (FrameLayout) findViewById(R.id.empty_view); mSavedInstanceState = savedInstanceState; // add the switch on Action bar LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); mSwitch = (Switch) inflater.inflate(R.layout.imageswitch_layout, null); final int padding = getResources().getDimensionPixelSize(R.dimen.action_bar_switch_padding); mSwitch.setPadding(0, 0, padding, 0); getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM); getActionBar().setCustomView(mSwitch, new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.END)); mSwitch.setOnCheckedChangeListener(this); // hide fragment firstly , then update it in onResume() according to switch status final FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); mPermissionsFragment = (PermissionsFragment) fragmentManager.findFragmentByTag(mPermissionsTag); mAppsFragment = (AppsFragment) fragmentManager.findFragmentByTag(mAppsTag); if (mPermissionsFragment == null) { mPermissionsFragment = new PermissionsFragment(); mAppsFragment = new AppsFragment(); transaction.add(R.id.tab_pager, mPermissionsFragment, mPermissionsTag); transaction.add(R.id.tab_pager, mAppsFragment, mAppsTag); }//from w w w . j av a 2 s . c o m transaction.hide(mPermissionsFragment); transaction.hide(mAppsFragment); transaction.commit(); fragmentManager.executePendingTransactions(); // set page adapter mTabPager = (ViewPager) findViewById(R.id.tab_pager); mTabPagerAdapter = new TabPagerAdapter(); mTabPager.setAdapter(mTabPagerAdapter); mTabPager.setOnPageChangeListener(mTabPagerListener); // Configure action bar mActionBarAdapter = new ActionBarAdapter(this, this, getActionBar()); boolean isShow = PermControlUtils.isPermControlOn(this); Log.d(TAG, "oncreate(), isShow " + isShow); }
From source file:com.evandroid.musica.MainLyricActivity.java
private LyricsViewFragment init(FragmentManager fragmentManager, boolean startEmpty) { LyricsViewFragment lyricsViewFragment = (LyricsViewFragment) fragmentManager .findFragmentByTag(LYRICS_FRAGMENT_TAG); if (lyricsViewFragment == null || lyricsViewFragment.isDetached()) lyricsViewFragment = new LyricsViewFragment(); lyricsViewFragment.startEmpty(startEmpty); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (!lyricsViewFragment.isAdded()) { fragmentTransaction.add(R.id.main_fragment_container, lyricsViewFragment, LYRICS_FRAGMENT_TAG); }//www . j a va 2 s. com Fragment[] activeFragments = getActiveFragments(); displayedFragment = getDisplayedFragment(activeFragments); for (Fragment fragment : activeFragments) if (fragment != null) { if (fragment != displayedFragment && !fragment.isHidden()) { fragmentTransaction.hide(fragment); fragment.onHiddenChanged(true); } else if (fragment == displayedFragment) fragmentTransaction.show(fragment); } fragmentTransaction.commit(); return lyricsViewFragment; }
From source file:org.dkf.jmule.activities.MainActivity.java
private FragmentTransaction hideFragments(FragmentTransaction ts) { return ts.hide(search).hide(transfers).hide(servers); }
From source file:org.restcomm.android.olympus.CallActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set window styles for fullscreen-window size. Needs to be done before // adding content. requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); setContentView(R.layout.activity_call); // Initialize UI btnHangup = (ImageButton) findViewById(R.id.button_hangup); btnHangup.setOnClickListener(this); btnAnswer = (ImageButton) findViewById(R.id.button_answer); btnAnswer.setOnClickListener(this); btnAnswerAudio = (ImageButton) findViewById(R.id.button_answer_audio); btnAnswerAudio.setOnClickListener(this); btnMuteAudio = (ImageButton) findViewById(R.id.button_mute_audio); btnMuteAudio.setOnClickListener(this); btnMuteVideo = (ImageButton) findViewById(R.id.button_mute_video); btnMuteVideo.setOnClickListener(this); btnKeypad = (ImageButton) findViewById(R.id.button_keypad); btnKeypad.setOnClickListener(this); lblCall = (TextView) findViewById(R.id.label_call); lblStatus = (TextView) findViewById(R.id.label_status); lblTimer = (TextView) findViewById(R.id.label_timer); alertDialog = new AlertDialog.Builder(CallActivity.this, R.style.SimpleAlertStyle).create(); PreferenceManager.setDefaultValues(this, "preferences.xml", MODE_PRIVATE, R.xml.preferences, false); prefs = PreferenceManager.getDefaultSharedPreferences(this); // Get Intent parameters. final Intent intent = getIntent(); if (intent.getAction().equals(RCDevice.ACTION_OUTGOING_CALL)) { btnAnswer.setVisibility(View.INVISIBLE); btnAnswerAudio.setVisibility(View.INVISIBLE); } else {/*from www. j a va 2s.com*/ btnAnswer.setVisibility(View.VISIBLE); btnAnswerAudio.setVisibility(View.VISIBLE); } keypadFragment = new KeypadFragment(); lblTimer.setVisibility(View.INVISIBLE); // these might need to be moved to Resume() btnMuteAudio.setVisibility(View.INVISIBLE); btnMuteVideo.setVisibility(View.INVISIBLE); btnKeypad.setVisibility(View.INVISIBLE); activityVisible = true; // open keypad FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(R.id.keypad_fragment_container, keypadFragment); ft.hide(keypadFragment); ft.commit(); }
From source file:org.chromium.chrome.browser.bookmark.ManageBookmarkActivity.java
/** * Creates and sets an action listener on the add/edit bookmark fragment. * @param addEditFragment The fragment that the listener should be attached to. *///from ww w . j a va 2 s. c o m private void setActionListenerOnAddEdit(final AddEditBookmarkFragment addEditFragment) { addEditFragment.setOnActionListener(new AddEditBookmarkFragment.OnActionListener() { @Override public void onCancel() { finishAddEdit(); } @Override public void onNodeEdited(long id) { finishAddEdit(); } @Override public void onFolderCreated(long id, String name) { finishAddEdit(); if (getFragmentManager().getBackStackEntryCount() != 0) { ((SelectBookmarkFolderFragment) addEditFragment.getTargetFragment()).executeFolderSelection(id, name); } } @Override public void triggerFolderSelection() { FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); boolean isRoot = getFragmentManager().getBackStackEntryCount() == 0; SelectBookmarkFolderFragment selectFolder = SelectBookmarkFolderFragment.newInstance( // Only allow the root add/edit bookmark UI to create new bookmark // folders during selection. isRoot, addEditFragment.getParentFolderId(), addEditFragment.isFolder()); selectFolder.setTargetFragment(addEditFragment, 0); setActionListenerOnFolderSelection(selectFolder); String tag = isRoot ? BASE_SELECT_FOLDER_FRAGMENT_TAG : ADD_FOLDER_SELECT_FOLDER_FRAGMENT_TAG; fragmentTransaction.add(android.R.id.content, selectFolder, tag); fragmentTransaction.hide(addEditFragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } @Override public void onRemove() { finishAddEdit(); } @Override public void setBackEnabled(boolean enabled) { mIsBackEnabled = enabled; } private void finishAddEdit() { if (getFragmentManager().getBackStackEntryCount() == 0) { finish(); } else { getFragmentManager().popBackStackImmediate(); } } }); }
From source file:com.geecko.QuickLyric.MainActivity.java
private void selectItem(int position) { FragmentManager fragmentManager = getFragmentManager(); Fragment newFragment;/*from www . ja v a 2s . co m*/ String tag; switch (position) { default: // Lyrics tag = LYRICS_FRAGMENT_TAG; newFragment = fragmentManager.findFragmentByTag(tag); if (newFragment == null || !(newFragment instanceof LyricsViewFragment)) newFragment = new LyricsViewFragment(); ((LyricsViewFragment) newFragment).showTransitionAnim = true; break; case 1: // Saved Lyrics tag = LOCAL_LYRICS_FRAGMENT_TAG; newFragment = fragmentManager.findFragmentByTag(tag); if (newFragment == null || !(newFragment instanceof LocalLyricsFragment)) newFragment = new LocalLyricsFragment(); ((LocalLyricsFragment) newFragment).showTransitionAnim = true; break; case 2: // Separator return; case 3: // Settings if (drawer instanceof DrawerLayout) ((DrawerLayout) drawer).closeDrawer(drawerView); drawer.postDelayed(new Runnable() { @Override public void run() { Intent settingsIntent = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(settingsIntent, 77); } }, 250); return; case 4: // Feedback return; case 5: // About Dialog if (drawer instanceof DrawerLayout) ((DrawerLayout) drawer).closeDrawer(drawerView); drawer.postDelayed(new Runnable() { @Override public void run() { Intent aboutIntent = new Intent(MainActivity.this, AboutActivity.class); startActivityForResult(aboutIntent, 77); } }, 250); return; } final Fragment activeFragment = getDisplayedFragment(getActiveFragments()); prepareAnimations(activeFragment); // Insert the fragment by replacing any existing fragment if (newFragment != activeFragment) { if (mActionMode != null) mActionMode.finish(); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(R.animator.slide_in_start, R.animator.slide_out_start, R.animator.slide_in_start, R.animator.slide_out_start); fragmentTransaction.hide(activeFragment); if (newFragment.isAdded()) fragmentTransaction.show(newFragment); else fragmentTransaction.add(id.main_fragment_container, newFragment, tag); ((CollapsingToolbarLayout) findViewById(R.id.toolbar_layout)).setCollapsedTitleTextColor(Color.WHITE); fragmentTransaction.commit(); if (activeFragment instanceof LyricsViewFragment || newFragment instanceof LyricsViewFragment) { final Fragment newFragmentCopy = newFragment; activeFragment.getView().postDelayed(new Runnable() { @Override public void run() { if (activeFragment instanceof LyricsViewFragment) { expandToolbar(false); showRefreshFab(false); } else if (newFragmentCopy instanceof LyricsViewFragment) { expandToolbar(true); showRefreshFab(true); } } }, getResources().getInteger(android.R.integer.config_longAnimTime)); } } if (drawer instanceof DrawerLayout && (newFragment == activeFragment)) ((DrawerLayout) drawer).closeDrawer(drawerView); }
From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java
/** * Hide panel from view.//w w w.j a va 2s . co m */ public void hidePanel(SplitPanel p) { Log.d(LOG, "ReaderActivity.hidePanel"); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); fragmentTransaction.hide(p); fragmentTransaction.commit(); }
From source file:com.android.contacts.activities.DialtactsActivity.java
/** * Goes back to usual Phone UI with tags. Previously selected Tag and associated Fragment * should be automatically focused again. *//*from w ww .java2 s . c om*/ private void exitSearchUi() { final ActionBar actionBar = getActionBar(); // Hide the search fragment, if exists. if (mSearchFragment != null) { mSearchFragment.setUserVisibleHint(false); final FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.hide(mSearchFragment); transaction.commitAllowingStateLoss(); } // We want to hide SearchView and show Tabs. Also focus on previously selected one. actionBar.setDisplayShowCustomEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); for (int i = 0; i < TAB_INDEX_COUNT; i++) { sendFragmentVisibilityChange(i, i == mViewPager.getCurrentItem()); } // Before exiting the search screen, reset swipe state. mDuringSwipe = false; mUserTabClick = false; mViewPager.setVisibility(View.VISIBLE); hideInputMethod(getCurrentFocus()); // Request to update option menu. invalidateOptionsMenu(); // See comments in onActionViewExpanded() mSearchView.onActionViewCollapsed(); mInSearchUi = false; }
From source file:com.geecko.QuickLyric.MainActivity.java
public void updateLyricsFragment(int outAnim, String... params) { // Should only be called from SearchFragment or IdDecoder String artist = params[0];/*from w ww .j av a2s. c o m*/ String song = params[1]; String url = null; if (params.length > 2) url = params[2]; LyricsViewFragment lyricsViewFragment = (LyricsViewFragment) getFragmentManager() .findFragmentByTag(LYRICS_FRAGMENT_TAG); if (lyricsViewFragment != null) lyricsViewFragment.fetchLyrics(artist, song, url); else { Lyrics lyrics = new Lyrics(Lyrics.SEARCH_ITEM); lyrics.setArtist(artist); lyrics.setTitle(song); lyrics.setURL(url); Bundle lyricsBundle = new Bundle(); try { if (artist != null && song != null) lyricsBundle.putByteArray("lyrics", lyrics.toBytes()); } catch (IOException e) { e.printStackTrace(); } lyricsViewFragment = new LyricsViewFragment(); lyricsViewFragment.setArguments(lyricsBundle); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(R.animator.slide_in_start, outAnim, R.animator.slide_in_start, outAnim); Fragment activeFragment = getDisplayedFragment(getActiveFragments()); if (activeFragment != null) { prepareAnimations(activeFragment); fragmentTransaction.hide(activeFragment); } fragmentTransaction.add(id.main_fragment_container, lyricsViewFragment, LYRICS_FRAGMENT_TAG); lyricsViewFragment.isActiveFragment = true; fragmentTransaction.commit(); } if (drawer instanceof DrawerLayout && !mDrawerToggle.isDrawerIndicatorEnabled()) { mDrawerToggle.setDrawerIndicatorEnabled(true); ((DrawerLayout) drawer).setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); } }
From source file:com.android.contacts.activities.DialtactsActivity.java
@Override public void onAttachFragment(Fragment fragment) { // This method can be called before onCreate(), at which point we cannot rely on ViewPager. // In that case, we will setup the "current position" soon after the ViewPager is ready. final int currentPosition = mViewPager != null ? mViewPager.getCurrentItem() : -1; if (fragment instanceof DialpadFragment) { mDialpadFragment = (DialpadFragment) fragment; } else if (fragment instanceof CallLogFragment) { mCallLogFragment = (CallLogFragment) fragment; } else if (fragment instanceof PhoneFavoriteFragment) { mPhoneFavoriteFragment = (PhoneFavoriteFragment) fragment; mPhoneFavoriteFragment.setListener(mPhoneFavoriteListener); if (mContactListFilterController != null && mContactListFilterController.getFilter() != null) { mPhoneFavoriteFragment.setFilter(mContactListFilterController.getFilter()); }/*www .ja v a 2s . c o m*/ } else if (fragment instanceof PhoneNumberPickerFragment) { mSearchFragment = (PhoneNumberPickerFragment) fragment; mSearchFragment.setOnPhoneNumberPickerActionListener(mPhoneNumberPickerActionListener); mSearchFragment.setQuickContactEnabled(true); mSearchFragment.setDarkTheme(true); mSearchFragment.setPhotoPosition(ContactListItemView.PhotoPosition.LEFT); mSearchFragment.setUseCallableUri(true); if (mContactListFilterController != null && mContactListFilterController.getFilter() != null) { mSearchFragment.setFilter(mContactListFilterController.getFilter()); } // Here we assume that we're not on the search mode, so let's hide the fragment. // // We get here either when the fragment is created (normal case), or after configuration // changes. In the former case, we're not in search mode because we can only // enter search mode if the fragment is created. (see enterSearchUi()) // In the latter case we're not in search mode either because we don't retain // mInSearchUi -- ideally we should but at this point it's not supported. mSearchFragment.setUserVisibleHint(false); // After configuration changes fragments will forget their "hidden" state, so make // sure to hide it. if (!mSearchFragment.isHidden()) { final FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.hide(mSearchFragment); transaction.commitAllowingStateLoss(); } } }