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:net.forkk.autocron.EditComponentActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_component);

    Intent intent = getIntent();//from  w  ww.j  av a2 s. c  o m
    assert intent != null;

    ComponentPointer pointer = (ComponentPointer) intent.getSerializableExtra(EXTRA_COMPONENT_POINTER);

    // Hack to get the title to display properly.
    String componentName = "";
    if (pointer instanceof Rule.Pointer)
        componentName = getString(R.string.rule_upper);
    if (pointer instanceof Action.Pointer)
        componentName = getString(R.string.action_upper);
    if (pointer instanceof Trigger.Pointer)
        componentName = getString(R.string.trigger_upper);
    setTitle(getString(R.string.title_activity_edit_component, componentName));

    if (savedInstanceState == null) {
        Bundle fragArgs = new Bundle();
        fragArgs.putSerializable(ComponentPreferenceFragment.VALUE_COMPONENT_POINTER, pointer);

        ComponentPreferenceFragment fragment = new ComponentPreferenceFragment();
        fragment.setArguments(fragArgs);

        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.fragment_edit_component_container, fragment);
        transaction.commit();
    }
}

From source file:com.liferay.social.activity.MainActivity.java

private void _replaceRightFragment(Fragment fragment, String tag) {
    FragmentManager manager = getFragmentManager();
    Fragment replacement = manager.findFragmentByTag(tag);

    if (replacement == null) {
        replacement = fragment;//from ww  w .ja  v  a 2  s  .  c  o m
    }

    FragmentTransaction transaction = manager.beginTransaction();
    transaction.replace(R.id.right_fragment, replacement, tag);
    transaction.commit();

    _drawer.closeDrawers();
}

From source file:com.qrcodereader.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getWindowManager().getDefaultDisplay().getSize(screenParametersPoint);
    layout = (RelativeLayout) findViewById(R.id.main_layout);
    if (savedInstanceState == null) {
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        fragmentTransaction.addToBackStack(null);
        fragmentTransaction.replace(layout.getId(), new FragmentDecoder());
        fragmentTransaction.commit();
    }/*from  w  w w.j av a2  s.c o m*/
}

From source file:com.explovia.mapdemo.ProgrammaticDemoActivity.java

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

    // It isn't possible to set a fragment's id programmatically so we set a tag instead and
    // search for it using that.
    mMapFragment = (MapFragment) getFragmentManager().findFragmentByTag(MAP_FRAGMENT_TAG);

    // We only create a fragment if it doesn't already exist.
    if (mMapFragment == null) {
        // To programmatically add the map, we first create a SupportMapFragment.
        mMapFragment = MapFragment.newInstance();

        // Then we add it using a FragmentTransaction.
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        fragmentTransaction.add(android.R.id.content, mMapFragment, MAP_FRAGMENT_TAG);
        fragmentTransaction.commit();
    }/*from ww w  .ja v a  2  s . c o m*/

    // We can't be guaranteed that the map is available because Google Play services might
    // not be available.
    setUpMapIfNeeded();
}

From source file:com.google.android.apps.santatracker.doodles.PineappleActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view);

    // Check for game direct launch
    DoodleConfig config;//w ww. j a v a 2s. c o  m
    if (getIntent() != null && getIntent().hasExtra(LaunchDecisionMaker.START_GAME_KEY)) {
        config = new DoodleConfig(getIntent().getExtras(), null);
    } else {
        throw new IllegalStateException("Extra START_GAME_KEY required");
    }

    // [ANALYTICS]
    mAnalytics = FirebaseAnalytics.getInstance(this);
    String gameKey = getIntent().getStringExtra(LaunchDecisionMaker.START_GAME_KEY);
    switch (gameKey) {
    case LaunchDecisionMaker.WATERPOLO_GAME_VALUE:
        MeasurementManager.recordScreenView(mAnalytics, getString(R.string.analytics_screen_waterpolo));
        break;
    case LaunchDecisionMaker.RUNNING_GAME_VALUE:
        MeasurementManager.recordScreenView(mAnalytics, getString(R.string.analytics_screen_running));
        break;
    case LaunchDecisionMaker.SWIMMING_GAME_VALUE:
        MeasurementManager.recordScreenView(mAnalytics, getString(R.string.analytics_screen_swimming));
        break;
    }

    appInvitesFragment = AppInvitesFragment.getInstance(this);

    logger = new PineappleDebugLogger();
    Fragment fragment = LaunchDecisionMaker.makeFragment(this, config, logger);
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.add(R.id.activity_wrapper, fragment, "menu");
    fragmentTransaction.commit();
}

From source file:edu.umich.titusj.tsr.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(edu.umich.titusj.tsr.R.layout.activity_main);
    getWindowManager().getDefaultDisplay().getSize(screenParametersPoint);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    layout = (FrameLayout) findViewById(edu.umich.titusj.tsr.R.id.main_layout);
    if (savedInstanceState == null) {
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        fragmentTransaction.addToBackStack(null);
        fragmentTransaction.replace(layout.getId(), new Camera2Fragment());
        fragmentTransaction.commit();
    }//from w  ww. j a  va  2 s.c  om
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.activities.LevelOneActivity.java

private void setFragment(Fragment fragment, String fragmentTag) {
    Log.d(TAG, "setFragment: " + fragmentTag);
    final FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.content_frame_level_one, fragment, fragmentTag);
    transaction.addToBackStack(null);//from   w w w .j  a  va2s .co  m
    transaction.commit();
}

From source file:com.example.android.leanback.VideoActivityWithDetailedCard.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.video_activity_detailed_card);

    if (savedInstanceState == null) {
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.add(R.id.videoFragment, new VideoConsumptionWithDetailCardFragment(),
                VideoConsumptionWithDetailCardFragment.TAG);
        ft.commit();
    }/*ww w . j  a v a  2  s  .  co  m*/
}

From source file:cz.zcu.kiv.eeg.mobile.base.ws.asynctask.FetchReservationsToDate.java

/**
 * Clears adapter of current data and fills it with fetched reservations.
 * In process it clears details fragment, so it could not display information about no longer existing reservation.
 *
 * @param resultList fetched reservations
 *//*w  w w  .ja  v a  2 s.  c om*/
@Override
protected void onPostExecute(List<Reservation> resultList) {
    reservationAdapter.clear();
    if (resultList != null && !resultList.isEmpty()) {
        for (Reservation reservation : resultList) {
            try {
                reservationAdapter.add(reservation);
            } catch (Exception e) {
                setState(ERROR, e);
                Log.e(TAG, e.getLocalizedMessage(), e);
            }
        }
    }

    FragmentManager fm = activity.getFragmentManager();

    ReservationDetailsFragment details = new ReservationDetailsFragment();
    ReservationDetailsFragment frag = (ReservationDetailsFragment) fm
            .findFragmentByTag(ReservationDetailsFragment.TAG);
    if (frag != null) {
        FragmentTransaction ft = fm.beginTransaction();
        ft.replace(R.id.details, details, ReservationDetailsFragment.TAG);
        ft.commit();
    }
}

From source file:com.louding.frame.ui.FrameActivity.java

/**
 * Fragment?/* w ww.ja  v  a2s.co m*/
 * 
 * @param resView
 *            ??
 * @param targetFragment
 *            ??Fragment
 */
public void changeFragment(int resView, KJFragment targetFragment) {
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(resView, targetFragment, targetFragment.getClass().getName());
    transaction.commit();
}