Java Code Examples for android.app.FragmentManager#popBackStackImmediate()

The following examples show how to use android.app.FragmentManager#popBackStackImmediate() . These examples are extracted from open source projects. 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
@Override
public void onBackPressed() {

    FragmentManager fm = getFragmentManager();
    if (fm.getBackStackEntryCount() > 1) {

        fm.popBackStackImmediate();
        SettingActivity.this.setTitle(R.string.title_activity_setting);
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);

    } else {

        clearMemory();
        finish();
    }
}
 
Example 2
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
	FragmentManager fm = getFragmentManager();
	FragmentTransaction transaction = fm.beginTransaction();

	/*if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
		if (newFragmentType.isRightOf(currentFragment)) {
			transaction.setCustomAnimations(R.anim.slide_in_right_to_left,
					R.anim.slide_out_right_to_left,
					R.anim.slide_in_left_to_right,
					R.anim.slide_out_left_to_right);
		} else {
			transaction.setCustomAnimations(R.anim.slide_in_left_to_right,
					R.anim.slide_out_left_to_right,
					R.anim.slide_in_right_to_left,
					R.anim.slide_out_right_to_left);
		}
	}*/

	if (newFragmentType != FragmentsAvailable.DIALER
			&& newFragmentType != FragmentsAvailable.CONTACTS_LIST
			&& newFragmentType != FragmentsAvailable.CHAT_LIST
			&& newFragmentType != FragmentsAvailable.HISTORY_LIST) {
		transaction.addToBackStack(newFragmentType.toString());
	} else {
		while (fm.getBackStackEntryCount() > 0) {
			fm.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
		}
	}

	transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString());
	transaction.commitAllowingStateLoss();
	fm.executePendingTransactions();

	currentFragment = newFragmentType;
}
 
Example 3
public void showChatRoomCreation(
        Address peerAddress,
        ArrayList<ContactAddress> participants,
        String subject,
        boolean encrypted,
        boolean isGroupChatRoom,
        boolean cleanBackStack) {
    if (cleanBackStack) {
        FragmentManager fm = getFragmentManager();
        while (fm.getBackStackEntryCount() > 0) {
            fm.popBackStackImmediate();
        }
        if (isTablet()) {
            showEmptyChildFragment();
        }
    }

    Bundle extras = new Bundle();
    if (peerAddress != null) {
        extras.putSerializable("RemoteSipUri", peerAddress.asStringUriOnly());
    }
    extras.putSerializable("Participants", participants);
    extras.putString("Subject", subject);
    extras.putBoolean("Encrypted", encrypted);
    extras.putBoolean("IsGroupChatRoom", isGroupChatRoom);

    ChatRoomCreationFragment fragment = new ChatRoomCreationFragment();
    fragment.setArguments(extras);
    changeFragment(fragment, "Chat room creation", true);
}
 
Example 4
@Override public void onBackPressed() {
    FragmentManager fragmentManager = getFragmentManager();
    if (mDrawerLayout.isDrawerOpen(mNavDrawer)) {
        mDrawerLayout.closeDrawers();
    } else if (fragmentManager.getBackStackEntryCount() != 0) {
        fragmentManager.popBackStackImmediate();
        configureFragment(
            fragmentManager.findFragmentById(R.id.content_frame)
        );
    } else {
        super.onBackPressed();
    }
}
 
Example 5
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_settings) {

        developerInfo();
        return true;

    }

    if (id == R.id.action_question) {

        questionsAnswer();
        return true;

    }

    if (id == android.R.id.home) {

        FragmentManager fm = getFragmentManager();
        if (fm.getBackStackEntryCount() > 1) {

            fm.popBackStackImmediate();
            SettingActivity.this.setTitle(R.string.title_activity_setting);
            getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        } else {

            super.onBackPressed();
        }

    }
    return super.onOptionsItemSelected(item);
}