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:gl.iglou.scenegraph.MatModeInterface.java

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    snapshotToast = Toast.makeText(this, "", Toast.LENGTH_LONG);

    LayoutInflater inflater = getLayoutInflater();

    arrow_l = getResources().getDrawable(R.drawable.scene_arrow_l);
    arrow_r = getResources().getDrawable(R.drawable.scene_arrow_r);
    arrowListener = new ArrowClickListener();

    currentSceneId = getIntent().getIntExtra("SCENE_ID", 0);
    SharedData.TYPE current_mode = SharedData.GetMode();

    setContentView(R.layout.scene_activity);

    mainLayout = (RelativeLayout) findViewById(R.id.content_frame);
    buttonGroup = findViewById(R.id.scene_button_frame);
    snapshotContainer = (FrameLayout) findViewById(R.id.scene_snapshot_container);
    //drawerStartId = getIdAssignedByR(this,"outliner_container");
    drawerStartId = R.id.outliner_container;
    drawerEndId = getIdAssignedByR(this, "gl_configurator_container");

    GLView = (GL2JNIView) findViewById(R.id.content_view);

    arrowL = (ImageView) findViewById(R.id.arrow_l);
    arrowR = (ImageView) findViewById(R.id.arrow_r);
    arrowL.setOnClickListener(arrowListener);
    arrowR.setOnClickListener(arrowListener);

    targetButton = (ImageButton) findViewById(R.id.scene_target);
    meshButton = (ImageButton) findViewById(R.id.scene_mesh_mode);
    AABBButton = (ImageButton) findViewById(R.id.scene_AABB_mode);

    selection = (TextView) findViewById(R.id.scene_selection);
    UpdateSelection();/*from  w  w w .  j  a  va  2 s . c  o m*/

    mDrawerLayout = (SceneDrawer) findViewById(R.id.drawer_layout);

    mDrawerLayout.setDrawerListener(new MyDrawerListener());
    mDrawerLayout.SetDrawerId(drawerStartId, drawerEndId);

    mDrawerLayout.setScrimColor(0x00ffffff);

    decorView = getWindow().getDecorView();

    outlinerFrag = new SceneOutlinerFragment();
    GLConfFrag = new SceneGLConfiguratorFragment();

    matModeView = inflater.inflate(R.layout.scene_mat_mode, null);
    mainLayout.addView(matModeView);
    if (SharedData.TYPE.MAT == current_mode) {
        //matModeView.setVisibility(View.VISIBLE);
        EnableMatMode(true);
    } else {
        EnableMatMode(false);
        //matModeView.setVisibility(View.INVISIBLE);
    }

    snapShot = inflater.inflate(R.layout.scene_snapshot_frame, null);
    snapshotContainer.addView(snapShot);
    photo = (ImageView) snapShot.findViewById(R.id.snapshot);
    snapshotIndicator = (ProgressBar) snapShot.findViewById(R.id.scene_snapshot_progress_bar);
    snapshotContainer.setVisibility(View.INVISIBLE);
    snapshotIndicator.setVisibility(View.INVISIBLE);

    FragmentManager fm = getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(R.id.outliner_container, outlinerFrag);
    ft.commit();

    FragmentTransaction ft0 = fm.beginTransaction();
    ft0.add(R.id.gl_configurator_container, GLConfFrag);
    ft0.commit();
    Log.v(TAG, "Activity ON_CREATE CALL");

}

From source file:me.isassist.isa.MainActivity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override/*from w w  w. java  2s .co  m*/
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    Fragment fragment = new ListFragment();
    Bundle args = new Bundle();

    if (mLastLocation == null) {
        Toast.makeText(this, "Waiting for the location...", Toast.LENGTH_LONG).show();
        return false;
    }

    switch (id) {
    case R.id.nav_atms: {
        args.putSerializable("API_TYPE", Bihapi.CASH_MACHINES);
        mListType = Bihapi.CASH_MACHINES;
        break;
    }
    case R.id.nav_bikes: {
        args.putSerializable("API_TYPE", Bihapi.VETURILO);
        mListType = Bihapi.VETURILO;
        break;
    }
    case R.id.nav_city_offices: {
        args.putSerializable("API_TYPE", Bihapi.CITY_OFFICES);
        mListType = Bihapi.CITY_OFFICES;
        break;
    }
    case R.id.nav_dormitories: {
        args.putSerializable("API_TYPE", Bihapi.DORMITORIES);
        mListType = Bihapi.DORMITORIES;
        break;
    }
    case R.id.nav_hotels: {
        args.putSerializable("API_TYPE", Bihapi.HOTELS);
        mListType = Bihapi.HOTELS;
        break;
    }
    case R.id.nav_pharmacies: {
        args.putSerializable("API_TYPE", Bihapi.PHARMACIES);
        mListType = Bihapi.PHARMACIES;
        break;
    }
    case R.id.nav_sport_fields: {
        args.putSerializable("API_TYPE", Bihapi.SPORT_FIELDS);
        mListType = Bihapi.SPORT_FIELDS;
        break;
    }
    case R.id.nav_swimming: {
        args.putSerializable("API_TYPE", Bihapi.SWIMMING_POOLS);
        mListType = Bihapi.SWIMMING_POOLS;
        break;
    }
    case R.id.nav_police_offices: {
        args.putSerializable("API_TYPE", Bihapi.POLICE_OFFICES);
        mListType = Bihapi.POLICE_OFFICES;
        break;
    }
    case R.id.nav_theaters: {
        args.putSerializable("API_TYPE", Bihapi.THEATRES);
        mListType = Bihapi.THEATRES;
        break;
    }
    }
    fragment.setArguments(args);

    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.replace(R.id.fragment_container, fragment);
    fragmentTransaction.addToBackStack(null);
    fragmentTransaction.commit();

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:com.andreykaraman.multinote.ui.list.AltNoteActivity.java

public void onArticleSelected(int position, long id) {
    // The user selected the headline of an article from the
    // HeadlinesFragment

    // Capture the article fragment from the activity layout
    AltEditNoteFragment articleFrag = (AltEditNoteFragment) getFragmentManager()
            .findFragmentById(R.id.fragment_new_note);

    if (articleFrag != null) {
        // If article frag is available, we're in two-pane layout...

        // Call a method in the ArticleFragment to update its content
        articleFrag.updateArticleView(position);

    } else {/*ww  w.  ja  v a2  s. c  o m*/
        // If the frag is not available, we're in the one-pane layout and
        // must swap frags...

        // Create fragment and give it an argument for the selected article
        AltEditNoteFragment newFragment = new AltEditNoteFragment();
        Bundle args = new Bundle();
        args.putLong(AltEditNoteFragment.ARG_ID, id);

        newFragment.setArguments(args);
        FragmentTransaction transaction = getFragmentManager().beginTransaction();

        // Replace whatever is in the fragment_container view with this
        // fragment,
        // and add the transaction to the back stack so the user can
        // navigate back
        transaction.replace(R.id.fragment_container, newFragment);
        transaction.addToBackStack(null);

        // Commit the transaction
        transaction.commit();
    }
}

From source file:com.esri.android.mapsapp.MapsAppActivity.java

/**
 * Opens the content browser that shows the user's maps.
 *///from   w ww  .  java  2s  .  c om
private void showContentBrowser() {
    FragmentManager fragmentManager = getFragmentManager();
    Fragment browseFragment = fragmentManager.findFragmentByTag(ContentBrowserFragment.TAG);
    if (browseFragment == null) {
        browseFragment = new ContentBrowserFragment();
    }

    if (!browseFragment.isVisible()) {
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.add(R.id.maps_app_activity_content_frame, browseFragment, ContentBrowserFragment.TAG);
        transaction.addToBackStack(null);
        transaction.commit();

        invalidateOptionsMenu(); // reload the options menu
    }

    mDrawerLayout.closeDrawers();
}

From source file:com.android.calendar.SearchActivity.java

private void initFragments(long timeMillis, String query) {
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction ft = fragmentManager.beginTransaction();

    AgendaFragment searchResultsFragment = new AgendaFragment(timeMillis, true);
    ft.replace(R.id.search_results, searchResultsFragment);
    mController.registerEventHandler(R.id.search_results, searchResultsFragment);

    ft.commit();
    Time t = new Time();
    t.set(timeMillis);/*from  www  . ja  va 2s  .c  o m*/
    search(query, t);
}

From source file:com.battlelancer.seriesguide.ui.SeriesGuidePreferences.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(SeriesGuidePreferences.THEME);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_singlepane);
    setupActionBar();//from ww  w.  j a v a2  s .  co m

    if (savedInstanceState == null) {
        Fragment f = new SettingsHeadersFragment();
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.add(R.id.content_frame, f);
        ft.commit();
    }
}

From source file:it.gmariotti.cardslib.demo.MainNativeActivity.java

private void openFragment(BaseFragment baseFragment) {
    if (baseFragment != null) {
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

        fragmentTransaction.replace(R.id.fragment_main, baseFragment);
        fragmentTransaction.addToBackStack(null);

        fragmentTransaction.commit();
        if (baseFragment.getTitleResourceId() > 0)
            mCurrentTitle = baseFragment.getTitleResourceId();

    }/*w ww. j av  a2  s.c  om*/
}

From source file:org.catnut.ui.PluginsActivity.java

public void flipCard(Fragment fragment, String tag, boolean backStack) {
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction/*from  www .  j  a v a 2  s .co m*/
            .setCustomAnimations(R.animator.card_flip_right_in, R.animator.card_flip_right_out,
                    R.animator.card_flip_left_in, R.animator.card_flip_left_out)
            .replace(android.R.id.content, fragment, tag);
    if (backStack) {
        fragmentTransaction.addToBackStack(null);
    }
    fragmentTransaction.commit();
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            invalidateOptionsMenu();
        }
    });
}

From source file:it.gmariotti.cardslib.demo.MainActivity.java

private void openFragment(BaseFragment baseFragment) {
    if (baseFragment != null) {
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

        fragmentTransaction.replace(R.id.fragment_main, baseFragment);
        //fragmentTransaction.addToBackStack(null);
        fragmentTransaction.commit();
        if (baseFragment.getTitleResourceId() > 0)
            mCurrentTitle = baseFragment.getTitleResourceId();

    }//  w w w  . j  a  v a  2 s.c o m
}

From source file:com.jose.castsocialconnector.main.MainActivity.java

private void showConnectWarningFragment() {
    ConnectWarningFragment menuFragment = new ConnectWarningFragment();
    menuFragment.setmMediaRouteSelector(mMediaRouteSelector);

    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(R.id.fragment_container, menuFragment).addToBackStack("");
    transaction.commit();
}