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:com.microsoft.office365.starter.FilesFolders.FileDetailActivity.java

private void updateActionHandler() {
    // Display the update fragment
    FileUpdateFragment updateFragment = new FileUpdateFragment();
    FragmentManager fragmentManager = getFragmentManager();
    android.app.FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.replace(R.id.file_detail_container, updateFragment, UPDATE_FRAGMENT_STACK_STATE);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    ft.addToBackStack(UPDATE_FRAGMENT_STACK_STATE);
    ft.commit();
}

From source file:com.android.messaging.ui.appsettings.PerSubscriptionSettingsActivity.java

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

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    final String title = getIntent().getStringExtra(UIIntents.UI_INTENT_EXTRA_PER_SUBSCRIPTION_SETTING_TITLE);
    if (!TextUtils.isEmpty(title)) {
        getSupportActionBar().setTitle(title);
    } else {// w  w  w  .jav  a  2s.c  om
        // This will fall back to the default title, i.e. "Messaging settings," so No-op.
    }

    final FragmentTransaction ft = getFragmentManager().beginTransaction();
    final PerSubscriptionSettingsFragment fragment = new PerSubscriptionSettingsFragment();
    ft.replace(android.R.id.content, fragment);
    ft.commit();
}

From source file:tv.piratemedia.lightcontroler.controlPreferences.java

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

    setContentView(R.layout.control_prefs);

    // Display the fragment as the main content.
    FragmentManager mFragmentManager = getFragmentManager();
    FragmentTransaction mFragmentTransaction = mFragmentManager.beginTransaction();
    PrefsFragment mPrefsFragment = new PrefsFragment();
    mFragmentTransaction.add(R.id.prefs_layout, mPrefsFragment);
    mFragmentTransaction.commit();

    if (Build.VERSION.SDK_INT == 21) {
        getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
    }//from   ww  w  .ja  va 2 s .  com

    mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mActionBarToolbar);
    mActionBarToolbar.setNavigationIcon(R.drawable.ic_ab_back_material);
    mActionBarToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            controlPreferences.this.finish();
        }
    });
}

From source file:com.cloudbees.gasp.activity.GaspRESTLoaderActivity.java

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

    // Set main content view for Gasp! Reviews
    setContentView(R.layout.gasp_review_activity);

    // Use the Fragments API to display review data
    FragmentManager fm = getFragmentManager();
    ListFragment list = (ListFragment) fm.findFragmentById(R.id.gasp_review_content);
    if (list == null) {
        list = new ListFragment();
        FragmentTransaction ft = fm.beginTransaction();
        ft.add(R.id.gasp_review_content, list);
        ft.commit();
    }//from  www. ja  va 2 s.c  o m

    // Array adapter provides access to the review list data
    mAdapter = new ArrayAdapter<String>(this, R.layout.gasp_review_list);
    list.setListAdapter(mAdapter);

    // Load shared preferences from res/xml/preferences.xml (first time only)
    // Subsequent activations will use the saved shared preferences from the device
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    SharedPreferences gaspSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    Log.i(TAG, "Using Gasp Server URI: " + gaspSharedPreferences.getString("gasp_endpoint_uri", ""));
    Uri gaspReviewsUri = Uri.parse(gaspSharedPreferences.getString("gasp_endpoint_uri", ""));

    // Loader arguments: LoaderManager will maintain the state of our Loaders
    // and reload if necessary. 
    Bundle args = new Bundle();
    Bundle params = new Bundle();
    args.putParcelable(ARGS_URI, gaspReviewsUri);
    args.putParcelable(ARGS_PARAMS, params);

    // Initialize the Loader.
    getLoaderManager().initLoader(LOADER_GASP_REVIEWS, args, this);

    // Use gasp-mongo REST service
    new ReviewsRequest().execute();

    try {
        LocationsRequest locations = new LocationsRequest(
                new SpatialQuery(new Location(-122.1139858, 37.3774655), 0.005));

        List<GeoLocation> locationList = locations.execute().get();
        for (GeoLocation geoLocation : locationList) {
            Log.i(TAG, geoLocation.getName());
            Log.i(TAG, " " + geoLocation.getFormattedAddress());
            Log.i(TAG, " " + String.valueOf(geoLocation.getLocation().getLng()));
            Log.i(TAG, " " + String.valueOf(geoLocation.getLocation().getLat()));
        }
    } catch (Exception e) {
        Log.e(TAG, e.getLocalizedMessage());
    }
}

From source file:org.dolphinemu.dolphinemu.gamelist.GameListActivity.java

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

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    // Construct list of items to add to the side menu.
    List<SideMenuItem> dir = new ArrayList<SideMenuItem>();
    dir.add(new SideMenuItem(getString(R.string.game_list), 0));
    dir.add(new SideMenuItem(getString(R.string.browse_folder), 1));
    dir.add(new SideMenuItem(getString(R.string.settings), 2));
    dir.add(new SideMenuItem(getString(R.string.about), 3));

    mDrawerAdapter = new SideMenuAdapter(this, R.layout.sidemenu, dir);
    mDrawerList.setAdapter(mDrawerAdapter);
    mDrawerList.setOnItemClickListener(mMenuItemClickListener);

    // Enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* Host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* Navigation drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {//  ww  w. j  a v a 2 s .c  om
        public void onDrawerClosed(View view) {
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    // Stuff in this block only happens when this activity is newly created (i.e. not a rotation)
    if (savedInstanceState == null) {
        // Copy assets into appropriate locations.
        Intent copyAssets = new Intent(this, AssetCopyService.class);
        startService(copyAssets);

        // Display the game list fragment.
        final GameListFragment gameList = new GameListFragment();
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.content_frame, gameList);
        ft.commit();
    }

    // Create an alert telling them that their phone sucks
    if (Build.CPU_ABI.contains("arm") && !NativeLibrary.SupportsNEON()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.device_compat_warning);
        builder.setMessage(R.string.device_compat_warning_msg);
        builder.setPositiveButton(R.string.yes, null);
        builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        builder.show();
    }
}

From source file:com.smassive.comicviewr.app.view.activity.MainActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    if (twoPanel) {
        FragmentTransaction fragmentTransaction = this.getFragmentManager().beginTransaction();
        Fragment detailFragment = getFragmentManager().findFragmentByTag(DETAIL_FRAGMENT);
        if (detailFragment != null) {
            fragmentTransaction.remove(detailFragment);
        }/*from  w  w  w .jav a  2 s.  c  o  m*/
        fragmentTransaction.commit();
    }

    super.onSaveInstanceState(outState);
}

From source file:it.mobistego.MainActivity.java

@Override
public void onMainFragmentGridItemSelected(MobiStegoItem mobiStegoItem) {
    if (mobiStegoItem != null) {
        ItemViewFragment viewFragment = new ItemViewFragment();
        Bundle args = new Bundle();
        viewFragment.setArguments(args);
        viewFragment.setMobiStegoItem(mobiStegoItem);
        FragmentTransaction transaction = getFragmentManager().beginTransaction();

        Fragment mainFrag = getFragmentManager().findFragmentByTag(Constants.CONTAINER);

        transaction.replace(mainFrag.getId(), viewFragment);
        transaction.addToBackStack(null);
        transaction.commit();
    }/*from ww  w  .j  a va2  s  .c o  m*/
}

From source file:com.dono.psakkos.dono.MainActivity.java

private void showKeyFragment() {
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    KeyFragment keyFragment = new KeyFragment();
    fragmentTransaction.replace(R.id.mainFragment, keyFragment);

    fragmentTransaction.commit();
}

From source file:com.google.android.apps.forscience.whistlepunk.LicenseActivity.java

private void showLicense(License license) {
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.add(R.id.container, LicenseFragment.newInstance(license), "license");
    ft.addToBackStack(license.key);//from  w  w  w  .  ja  v a  2  s .  c  o  m
    ft.commit();
}

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

private void deleteEvent(long eventId, long startMillis, long endMillis) {
    mDeleteEventHelper.delete(startMillis, endMillis, eventId, -1);
    if (mIsMultipane && mEventInfoFragment != null && eventId == mCurrentEventId) {
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();
        ft.remove(mEventInfoFragment);/*from  w  ww  .  java  2s . c  om*/
        ft.commit();
        mEventInfoFragment = null;
        mCurrentEventId = -1;
    }
}