Example usage for android.app FragmentTransaction commit

List of usage examples for android.app FragmentTransaction commit

Introduction

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

Prototype

public abstract int commit();

Source Link

Document

Schedules a commit of this transaction.

Usage

From source file:org.eyeseetea.malariacare.DashboardActivity.java

public void replaceFragment(int layout, Fragment fragment) {
    FragmentTransaction ft = getFragmentTransaction();
    ft.replace(layout, fragment);//from w  ww  .  jav  a2  s  .  co  m
    ft.commit();
}

From source file:org.eyeseetea.malariacare.DashboardActivity.java

public void replaceListFragment(int layout, ListFragment fragment) {
    FragmentTransaction ft = getFragmentTransaction();
    ft.replace(layout, fragment);//from  w  w  w  .  j a v a  2s  .  c  om
    ft.commit();
}

From source file:it.scoppelletti.mobilepower.app.FragmentLayoutController.java

/**
 * Ricostruisce la successione dei frammenti nell’unico pannello.
 * //  w  w w  .jav a  2s  .  c o  m
 * @param  fragmentMgr   Gestore dei frammenti.
 * @param  fragmentQueue Frammenti.
 * @return               Identificatore dell’ultimo elemento inserito
 *                       nel back stack. 
 */
private int arrangePanel(FragmentManager fragmentMgr,
        Queue<FragmentLayoutController.FragmentEntry> fragmentQueue) {
    int tnId, lastTnId;
    FragmentLayoutController.FragmentEntry entry;
    FragmentTransaction fragmentTn = null;

    lastTnId = -1;
    while (!fragmentQueue.isEmpty()) {
        tnId = -1;
        entry = fragmentQueue.remove();

        try {
            fragmentTn = fragmentMgr.beginTransaction();

            fragmentTn.replace(myFrameIds[0], entry.getFragment().asFragment(), entry.getTag());

            fragmentTn.addToBackStack(null);
        } finally {
            if (fragmentTn != null) {
                tnId = fragmentTn.commit();
                fragmentTn = null;
            }
        }

        if (tnId >= 0) {
            lastTnId = tnId;
        }
    }

    return lastTnId;
}

From source file:it.angrydroids.epub3reader.MainActivity.java

public void attachPanel(SplitPanel p) {
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.attach(p);//from   www  .  j a v  a 2 s.c  om
    fragmentTransaction.commit();

    panelCount++;
}

From source file:it.angrydroids.epub3reader.MainActivity.java

public void detachPanel(SplitPanel p) {
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.detach(p);/*from  ww w . ja  v a2s  .  c  o  m*/
    fragmentTransaction.commit();

    panelCount--;
}

From source file:it.angrydroids.epub3reader.MainActivity.java

public void removePanelWithoutClosing(SplitPanel p) {
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.remove(p);//from  www  .  j av  a 2  s  .c om
    fragmentTransaction.commit();

    panelCount--;
}

From source file:it.angrydroids.epub3reader.MainActivity.java

public void removePanel(SplitPanel p) {
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.remove(p);/* w  w w. ja v a 2  s.co m*/
    fragmentTransaction.commit();

    panelCount--;
    if (panelCount <= 0)
        finish();
}

From source file:leoisasmendi.android.com.suricatepodcast.MainActivity.java

private void initFragments() {
    fragmentManager = getFragmentManager();
    Log.d(TAG, "onCreate: twoPaneMode " + getResources().getBoolean(R.bool.twoPaneMode));
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    if (getResources().getBoolean(R.bool.twoPaneMode)) {

        fragmentTransaction//from  ww  w. j ava  2s . com
                .replace(R.id.master_container, new MainFragment(), MainFragment.class.getSimpleName()).replace(
                        R.id.detail_container, new DetailFragment(), MediaPlayerFragment.class.getSimpleName());

    } else { //Single panel view
        fragmentTransaction.replace(R.id.master_container, new MainFragment(),
                MainFragment.class.getSimpleName());
    }

    fragmentTransaction.commit();
}

From source file:org.kymjs.kjframe.KJActivity.java

/**
 * Fragment?//from  w w  w . j a va 2s.c  o  m
 *
 * @param resView        ??
 * @param targetFragment ??Fragment
 * @param isBack  ??true
 */
public void changeFragment(int resView, KJFragment targetFragment, boolean isBack) {
    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);
    }
    if (isBack) {
        transaction.addToBackStack(null);
    }
    currentKJFragment = targetFragment;
    transaction.commit();
}

From source file:com.github.chenxiaolong.dualbootpatcher.MainActivity.java

private void hideFragments(boolean animate) {
    FragmentManager fm = getFragmentManager();

    Fragment prevRoms = fm.findFragmentByTag(SwitcherListFragment.TAG);
    Fragment prevPatchFile = fm.findFragmentByTag(PatchFileFragment.TAG);
    Fragment prevFreeSpace = fm.findFragmentByTag(FreeSpaceFragment.TAG);
    Fragment prevAbout = fm.findFragmentByTag(AboutFragment.TAG);

    FragmentTransaction ft = fm.beginTransaction();

    if (animate) {
        ft.setCustomAnimations(0, R.animator.fragment_out);
    }/*w  ww.j  a v a 2 s .  c  om*/

    if (prevRoms != null) {
        ft.hide(prevRoms);
    }
    if (prevPatchFile != null) {
        ft.hide(prevPatchFile);
    }
    if (prevFreeSpace != null) {
        ft.hide(prevFreeSpace);
    }
    if (prevAbout != null) {
        ft.hide(prevAbout);
    }

    ft.commit();
    fm.executePendingTransactions();
}