Java Code Examples for android.app.fragmenttransaction#hide()

The following examples show how to use android.app.fragmenttransaction#hide() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From QuickLyric with GNU General Public License v3.0 6 votes vote down vote up
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();
    fragmentTransaction.setCustomAnimations(R.animator.slide_in_end, R.animator.slide_out_start, R.animator.slide_in_start, R.animator.slide_out_end);
    if (!lyricsViewFragment.isAdded()) {
        fragmentTransaction.add(id.main_fragment_container, lyricsViewFragment, LYRICS_FRAGMENT_TAG);
    }

    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;
}
 
Example 2
Source File: ConversationsActivity.java    From skype-android-app-sdk-samples with MIT License 6 votes vote down vote up
public void onParticipantsButtonClicked(android.view.View view) {
    this.rosterFragment = RosterFragment.newInstance(this.currentConversation);

    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();

    // Hide the current fragment.
    fragmentTransaction.hide(this.chatFragment);
    fragmentTransaction.add(R.id.fragment_container, this.rosterFragment, null);
    fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);

    // Add transaction to back stack so that "back" button restores state.
    fragmentTransaction.addToBackStack(null);

    // Load the fragment.
    fragmentTransaction.commit();

    this.participantsButton = (Button)view;
    participantsButton.setEnabled(false);

    this.conversationsToolbarLayout.setVisibility(View.GONE);
}
 
Example 3
Source File: ConversationsActivity.java    From skype-android-app-sdk-samples with MIT License 6 votes vote down vote up
public void onVideoButtonClicked(android.view.View view) {
    this.videoFragment = VideoFragment.newInstance(this.currentConversation, devicesManager);

    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();

    // Hide the current fragment.
    fragmentTransaction.hide(this.chatFragment);
    fragmentTransaction.add(R.id.fragment_container, this.videoFragment, null);
    fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);

    // Add transaction to back stack so that "back" button restores state.
    fragmentTransaction.addToBackStack(null);

    // Load the fragment.
    fragmentTransaction.commit();

    this.videoButton = (Button)view;
    videoButton.setEnabled(false);

    this.conversationsToolbarLayout.setVisibility(View.GONE);
}
 
Example 4
Source File: MainActivity.java    From BlackLight with GNU General Public License v3.0 6 votes vote down vote up
private void switchTo(int id) {
	FragmentTransaction ft = mManager.beginTransaction();
	ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out, android.R.animator.fade_in, android.R.animator.fade_out);
	
	for (int i = 0; i < mFragments.length; i++) {
		Fragment f = mFragments[i];
		
		if (f != null) {
			if (i != id) {
				ft.hide(f);
			} else {
				ft.show(f);
			}
		}
	}
	
	ft.commit();
}
 
Example 5
Source File: KJActivity.java    From KJFrameForAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * 用Fragment替换视图
 *
 * @param resView        将要被替换掉的视图
 * @param targetFragment 用来替换的Fragment
 */
public void changeFragment(int resView, KJFragment targetFragment) {
    if (targetFragment.equals(currentKJFragment)) {
        return;
    }
    FragmentTransaction transaction = getFragmentManager()
            .beginTransaction();
    if (!targetFragment.isAdded()) {
        transaction.add(resView, targetFragment, targetFragment.getClass()
                .getName());
    }
    if (targetFragment.isHidden()) {
        transaction.show(targetFragment);
        targetFragment.onChange();
    }
    if (currentKJFragment != null && currentKJFragment.isVisible()) {
        transaction.hide(currentKJFragment);
    }
    currentKJFragment = targetFragment;
    transaction.commit();
}
 
Example 6
Source File: GilgaMeshActivity.java    From gilgamesh with GNU General Public License v3.0 5 votes vote down vote up
private void showInfo ()
{
 FragmentManager fm = getFragmentManager();
 FragmentTransaction ft = fm.beginTransaction();
 ft.hide(fm.findFragmentById(R.id.status_list));
 ft.show(fm.findFragmentById(R.id.info_screen));
 ft.hide(fm.findFragmentById(R.id.device_list));
 
  ft.commit();
}
 
Example 7
Source File: Utilities.java    From rss with GNU General Public License v3.0 5 votes vote down vote up
private static
void switchToFragment(Fragment fragment, boolean addToBackStack)
{
    if(fragment.isHidden())
    {
        Fragment[] fragments = {
                s_fragmentFavourites, s_fragmentManage, s_fragmentFeeds, s_fragmentSettings
        };
        FragmentTransaction transaction = s_fragmentManager.beginTransaction();

        for(Fragment frag : fragments)
        {
            if(frag.isVisible())
            {
                transaction.hide(frag);
            }
        }
        transaction.show(fragment);
        if(addToBackStack)
        {
            transaction.addToBackStack(null);

            // Set the default transition for adding to the stack.
            transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        }
        transaction.commit();
        s_fragmentManager.executePendingTransactions();
        fragment.getActivity().invalidateOptionsMenu();
    }
}
 
Example 8
Source File: Constants.java    From rss with GNU General Public License v3.0 5 votes vote down vote up
static
void hideFragments(Fragment... fragments)
{
    FragmentTransaction transaction = s_fragmentManager.beginTransaction();
    for(Fragment fragment : fragments)
    {
        transaction.hide(fragment);
    }
    transaction.commit();
}
 
Example 9
Source File: CameraPreview.java    From cordova-plugin-camera-preview with MIT License 5 votes vote down vote up
private boolean hideCamera(CallbackContext callbackContext) {
  if(this.hasView(callbackContext) == false){
    return true;
  }

  FragmentManager fragmentManager = cordova.getActivity().getFragmentManager();
  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  fragmentTransaction.hide(fragment);
  fragmentTransaction.commit();

  callbackContext.success();
  return true;
}
 
Example 10
Source File: GilgaMeshActivity.java    From gilgamesh with GNU General Public License v3.0 5 votes vote down vote up
private void showStatus ()
{
FragmentManager fm = getFragmentManager();
 FragmentTransaction ft = fm.beginTransaction();
 ft.show(fm.findFragmentById(R.id.status_list));
 ft.hide(fm.findFragmentById(R.id.device_list));
 ft.hide(fm.findFragmentById(R.id.info_screen));

  ft.commit();
}
 
Example 11
Source File: MainActivity.java    From MBEStyle with GNU General Public License v3.0 5 votes vote down vote up
private void switchFragment(int index) {
    if (index == mCurrentIndex) return;

    Fragment fragment = mFragments.get(index);
    FragmentTransaction transaction =
            mFragmentManager
                    .beginTransaction()
                    .setCustomAnimations(R.animator.fragment_in, R.animator.fragment_out);

    String indexString = String.valueOf(index);
    Fragment targetFragment = mFragmentManager.findFragmentByTag(indexString);

    if (mCurrentIndex != -1) {
        // 不是首次启动
        transaction.hide(mFragments.get(mCurrentIndex));
    }

    if (targetFragment == null) {
        // 之前没有添加过
        transaction.add(R.id.fl_content, fragment, indexString);
    } else {
        transaction.show(targetFragment);
    }

    transaction.commit();
    mCurrentIndex = index;
}
 
Example 12
Source File: CallActivity.java    From restcomm-android-sdk with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onFragmentInteraction(String action) {
    if (action.equals("cancel")) {
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.hide(keypadFragment);
        ft.commit();

    }
}
 
Example 13
Source File: HomeActivity.java    From LoveTalkClient with Apache License 2.0 5 votes vote down vote up
private void hideFragments(FragmentTransaction transaction) {
	Fragment[] fragments = new Fragment[]{
			conversationFragment, contactFragment,
			discoverFragment, mySpaceFragment
	};
	for (Fragment f : fragments) {
		if (f != null) {
			transaction.hide(f);
		}
	}
}
 
Example 14
Source File: FragmentMenu.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
void updateFragmentVisibility() {
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    if (mCheckBox1.isChecked()) ft.show(mFragment1);
    else ft.hide(mFragment1);
    if (mCheckBox2.isChecked()) ft.show(mFragment2);
    else ft.hide(mFragment2);
    ft.commit();
}
 
Example 15
Source File: UserActivity.java    From UPMiss with GNU General Public License v3.0 5 votes vote down vote up
private void navToFragment(boolean isMain) {
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    if (isMain) {
        fragmentTransaction.show(mMain);
        mToolbar.setTitle(R.string.title_activity_user);
        mIsMain = true;
    } else {
        fragmentTransaction.hide(mMain);


        mToolbar.setTitle(R.string.title_activity_follow);
        mIsMain = false;
    }
    fragmentTransaction.commit();
}
 
Example 16
Source File: GilgaMeshActivity.java    From gilgamesh with GNU General Public License v3.0 5 votes vote down vote up
private void showNearby ()
{
 FragmentManager fm = getFragmentManager();
 FragmentTransaction ft = fm.beginTransaction();
 ft.hide(fm.findFragmentById(R.id.status_list));
 ft.hide(fm.findFragmentById(R.id.info_screen));
 ft.show(fm.findFragmentById(R.id.device_list));
 
  ft.commit();
}
 
Example 17
Source File: FragmentUtil.java    From SmallGdufe-Android with GNU General Public License v3.0 5 votes vote down vote up
/**使用本方法前必须先add*/
public void show(Fragment fragment){
    if (currentFragment==fragment) {
        return;//如果是当前fragment,则不重新show一遍了,无意义
    }
    FragmentTransaction ft = fm.beginTransaction();
    for (Fragment f:fs) {
        ft.hide(f);
    }
    ft.show(fragment);
    ft.commit();
    currentFragment = fragment;
}
 
Example 18
Source File: CallActivity.java    From restcomm-android-sdk with GNU Affero General Public License v3.0 4 votes vote down vote up
@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 {
        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();
}
 
Example 19
Source File: DialtactsActivity.java    From coursera-android with MIT License 4 votes vote down vote up
@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());
        }
    } 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();
        }
    }
}
 
Example 20
Source File: MainActivity.java    From QuickLyric with GNU General Public License v3.0 4 votes vote down vote up
public void updateLyricsFragment(int outAnim, String... params) { // Should only be called from SearchFragment or IdDecoder
    String artist = params[0];
    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) {
        if (!lyricsViewFragment.isActiveFragment) {
            selectItem(0);
        }
        lyricsViewFragment.fetchLyrics(true, null, 0L, params);
    } 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);
    }
}