Example usage for android.app FragmentTransaction commitAllowingStateLoss

List of usage examples for android.app FragmentTransaction commitAllowingStateLoss

Introduction

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

Prototype

public abstract int commitAllowingStateLoss();

Source Link

Document

Like #commit but allows the commit to be executed after an activity's state is saved.

Usage

From source file:com.android.mail.ui.TwoPaneController.java

/**
 * Render the conversation list in the correct pane.
 *///from  www.j a va2s.  c  o m
private void renderConversationList() {
    if (mActivity == null) {
        return;
    }
    FragmentTransaction fragmentTransaction = mActivity.getFragmentManager().beginTransaction();
    // Use cross fading animation.
    fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    final Fragment conversationListFragment = ConversationListFragment.newInstance(mConvListContext);
    fragmentTransaction.replace(R.id.conversation_list_pane, conversationListFragment, TAG_CONVERSATION_LIST);
    fragmentTransaction.commitAllowingStateLoss();
}

From source file:co.taqat.call.assistant.AssistantActivity.java

private void changeFragment(Fragment newFragment) {
    hideKeyboard();/*  w ww.j  a v a 2s .c om*/
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.fragment_container, newFragment);
    transaction.commitAllowingStateLoss();
}

From source file:com.mediatek.engineermode.EngineerMode.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);/*  ww w  . java2s .c o  m*/

    final FragmentManager fragmentManager = getFragmentManager();
    final FragmentTransaction transaction = fragmentManager.beginTransaction();

    if (isWifiOnly()) {
        TAB_TITLE_IDS = TAB_TITLE_IDS_WIFIONLY;
        TAB_COUNT = TAB_COUNT_WIFIONLY;
    }

    Log.v("@M_" + TAG, "new fregments");
    for (int i = 0; i < TAB_COUNT; i++) {
        mTabs[i] = new PrefsFragment();
        mTabs[i].setResource(i);
        transaction.add(R.id.viewpager, mTabs[i], String.valueOf(i));
        transaction.hide(mTabs[i]);
    }

    ViewPager viewPager;
    PagerTabStrip pagerTabStrip;

    viewPager = (ViewPager) findViewById(R.id.viewpager);
    pagerTabStrip = (PagerTabStrip) findViewById(R.id.pagertitle);
    pagerTabStrip.setTabIndicatorColorResource(android.R.color.holo_blue_light);

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

    mPagerAdapter = new MyPagerAdapter();
    viewPager.setAdapter(mPagerAdapter);
    viewPager.setCurrentItem(0);
}

From source file:com.benlinskey.greekreference.MainActivity.java

/**
 * Displays the specified Overview of Greek Syntax section in a {@link SyntaxDetailFragment}.
 * @param section the selected section's title
 * @param xml the selected section's XML
 *///from w ww . jav  a2  s  .c  o  m
void displaySyntaxSection(String section, String xml) {
    if (mTwoPane) {
        Bundle arguments = new Bundle();
        arguments.putString(SyntaxDetailFragment.ARG_XML, xml);
        SyntaxDetailFragment fragment = new SyntaxDetailFragment();
        fragment.setArguments(arguments);
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.item_detail_container, fragment);
        transaction.commitAllowingStateLoss();
    } else {
        SyntaxListFragment fragment = (SyntaxListFragment) getFragmentManager()
                .findFragmentById(R.id.item_list_container);
        int syntaxId = fragment.getSelectedSyntaxId();

        Intent intent = new Intent(this, SyntaxDetailActivity.class);
        intent.putExtra(SyntaxDetailFragment.ARG_XML, xml);
        intent.putExtra(SyntaxDetailActivity.ARG_SYNTAX_ID, syntaxId);
        intent.putExtra(SyntaxDetailActivity.ARG_SECTION, section);
        startActivity(intent);
    }
}

From source file:com.benlinskey.greekreference.MainActivity.java

/**
 * Displays the specified lexicon entry in a {@link LexiconDetailFragment}.
 * @param id the lexicon database ID of the selected entry
 * @param word the word whose entry is selected
 * @param entry the selected entry's XML
 *///from w w w .  j ava  2  s .  com
void displayLexiconEntry(final String id, String word, String entry) {
    // If user searches from Quick Search Box, we may need to change mode.
    if (!mMode.equals(Mode.LEXICON_BROWSE) && !mMode.equals(Mode.LEXICON_FAVORITES)
            && !mMode.equals(Mode.LEXICON_HISTORY)) {
        switchToLexiconBrowse();
    }

    // Add entry to history, unless word was selected from history list.
    if (!mMode.equals(Mode.LEXICON_HISTORY)) {
        addHistory(id, word);
    }

    // Display entry.
    if (mTwoPane) {
        Bundle arguments = new Bundle();
        arguments.putString(LexiconDetailFragment.ARG_ENTRY, entry);
        LexiconDetailFragment fragment = new LexiconDetailFragment();
        fragment.setArguments(arguments);
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.item_detail_container, fragment);
        transaction.commitAllowingStateLoss();
    } else {
        LexiconListFragment fragment = (LexiconListFragment) getFragmentManager()
                .findFragmentById(R.id.item_list_container);
        int lexiconId = fragment.getSelectedLexiconId();

        Intent intent = new Intent(this, LexiconDetailActivity.class);
        intent.putExtra(LexiconDetailFragment.ARG_ENTRY, entry);
        intent.putExtra(LexiconDetailActivity.ARG_LEXICON_ID, lexiconId);
        intent.putExtra(LexiconDetailActivity.ARG_WORD, word);
        startActivity(intent);
    }
}

From source file:com.frostwire.android.gui.activities.MainActivity.java

private void switchContent(Fragment fragment, boolean addToStack) {
    hideFragments();/* w ww  .j a v a  2  s  .  co  m*/
    FragmentTransaction transaction = getFragmentManager().beginTransaction().show(fragment);
    try {
        transaction.commitAllowingStateLoss();
    } catch (Throwable ignored) {
    }
    if (addToStack && (fragmentsStack.isEmpty() || fragmentsStack.peek() != fragment.getId())) {
        fragmentsStack.push(fragment.getId());
    }
    currentFragment = fragment;
    updateHeader(fragment);
    if (currentFragment instanceof MainFragment) {
        ((MainFragment) currentFragment).onShow();
    }
}

From source file:com.hijacker.MainActivity.java

static void isolate(String mac) {
    is_ap = getAPByMac(mac);//from w  w  w. j a  v  a 2 s  .c o m
    if (is_ap != null) {
        IsolatedFragment.exit_on = mFragmentManager.getBackStackEntryCount();
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        ft.replace(R.id.fragment1, new IsolatedFragment());
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        ft.addToBackStack(null);
        ft.commitAllowingStateLoss();
    }
    Tile.filter();
    if (debug) {
        if (is_ap == null)
            Log.d("HIJACKER/Main", "No AP isolated");
        else
            Log.d("HIJACKER/Main", "AP with MAC " + mac + " isolated");
    }
}

From source file:de.lespace.apprtc.ConnectActivity.java

@Override
public void onIncomingCall(final String from) {

    // Notify UI that registration has completed, so the progress indicator can be hidden.
    /*/* ww  w  .j  a  va2 s .  c  o m*/
            //Send Broadcast message to Service
            Intent registrationComplete = new Intent(QuickstartPreferences.INCOMING_CALL);
            LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
            
            startActivity(intent);*/

    /* Intent intent = new Intent(this, ConnectActivity.class);
     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     startActivity(intent);
     Intent intent = new Intent(this,CallActivity.class);
     intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);*/
    // r.stop();
    //startActivity(intent);

    roomConnectionParameters.to = from;
    roomConnectionParameters.initiator = false;
    DialogFragment newFragment = new RTCConnection.CallDialogFragment();

    Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);

    if (alert == null) {
        // alert is null, using backup
        alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        // I can't see this ever being null (as always have a default notification)
        // but just incase
        if (alert == null) {
            // alert backup is null, using 2nd backup
            alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALL);
        }
    }
    r = RingtoneManager.getRingtone(getApplicationContext(), alert);
    //  r.play();

    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.add(newFragment, "loading");
    transaction.commitAllowingStateLoss();

}

From source file:com.breadwallet.presenter.activities.IntroActivity.java

private void createFragments() {
    introWelcomeFragment = new IntroWelcomeFragment();
    introNewRecoverFragment = new IntroNewRecoverFragment();
    introNewWalletFragment = new IntroNewWalletFragment();
    introRecoverWalletFragment = new IntroRecoverWalletFragment();
    introWarningFragment = new IntroWarningFragment();

    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    fragmentTransaction.add(R.id.intro_layout, introWelcomeFragment, IntroWelcomeFragment.class.getName());
    fragmentTransaction.add(R.id.intro_layout, introNewRecoverFragment,
            IntroNewRecoverFragment.class.getName());
    fragmentTransaction.add(R.id.intro_layout, introNewWalletFragment, IntroNewWalletFragment.class.getName());
    fragmentTransaction.add(R.id.intro_layout, introRecoverWalletFragment,
            IntroRecoverWalletFragment.class.getName());
    fragmentTransaction.add(R.id.intro_layout, introWarningFragment, IntroWarningFragment.class.getName());

    showHideFragments(introWelcomeFragment);
    newRecoverNoneFlag = 0;//from w  w w  .  j  av  a 2  s.  com
    fragmentTransaction.commitAllowingStateLoss();
}

From source file:dev.dworks.apps.anexplorer.fragment.DirectoryFragment.java

private static void show(FragmentManager fm, int type, RootInfo root, DocumentInfo doc, String query,
        int anim) {
    final Bundle args = new Bundle();
    args.putInt(EXTRA_TYPE, type);/*from  w  w  w. ja v  a  2s .  c  om*/
    args.putParcelable(EXTRA_ROOT, root);
    args.putParcelable(EXTRA_DOC, doc);
    args.putString(EXTRA_QUERY, query);

    final FragmentTransaction ft = fm.beginTransaction();
    switch (anim) {
    case ANIM_SIDE:
        args.putBoolean(EXTRA_IGNORE_STATE, true);
        break;
    case ANIM_DOWN:
        args.putBoolean(EXTRA_IGNORE_STATE, true);
        ft.setCustomAnimations(R.animator.dir_down, R.animator.dir_frozen);
        break;
    case ANIM_UP:
        ft.setCustomAnimations(R.animator.dir_frozen, R.animator.dir_up);
        break;
    }

    final DirectoryFragment fragment = new DirectoryFragment();
    fragment.setArguments(args);

    ft.replace(R.id.container_directory, fragment);
    ft.commitAllowingStateLoss();
}