Example usage for android.support.v4.app FragmentManager findFragmentById

List of usage examples for android.support.v4.app FragmentManager findFragmentById

Introduction

In this page you can find the example usage for android.support.v4.app FragmentManager findFragmentById.

Prototype

public abstract Fragment findFragmentById(int id);

Source Link

Document

Finds a fragment that was identified by the given id either when inflated from XML or as the container ID when added in a transaction.

Usage

From source file:com.money.manager.ex.recurring.transactions.RecurringTransactionListActivity.java

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

    // check if launch from notification
    if (getIntent() != null && getIntent().getBooleanExtra(INTENT_EXTRA_LAUNCH_NOTIFICATION, false)) {
        Passcode passcode = new Passcode(getApplicationContext());
        if (passcode.hasPasscode()) {
            Intent intent = new Intent(this, PasscodeActivity.class);
            // set action and data
            intent.setAction(PasscodeActivity.INTENT_REQUEST_PASSWORD);
            intent.putExtra(PasscodeActivity.INTENT_MESSAGE_TEXT, getString(R.string.enter_your_passcode));
            // start activity
            startActivityForResult(intent, INTENT_REQUEST_PASSCODE);
        }//from w  w w  . j  av a 2s  .c  o  m
    }
    // set actionbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // set fragment and fragment manager
    FragmentManager fm = getSupportFragmentManager();
    listFragment = new RecurringTransactionListFragment();
    // attach fragment on activity
    if (fm.findFragmentById(R.id.content) == null) {
        fm.beginTransaction().add(R.id.content, listFragment, FRAGMENTTAG).commit();
    }

    Answers.getInstance().logCustom(new CustomEvent(AnswersEvents.RecurringTransactionList.name()));
}

From source file:dev.drsoran.moloko.auth.AuthenticatorActivity.java

private void createStartFragment() {
    final FragmentManager fragmentManager = getSupportFragmentManager();

    if (fragmentManager.findFragmentById(R.id.frag_multi_container) == null) {
        final Fragment startFragment = chooseStartFragmentByIntentData();

        fragmentManager.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                .add(R.id.frag_multi_container, startFragment).commit();
    }/*from ww w.j ava  2  s . c  o  m*/
}

From source file:com.example.levelup.core.app.example3.PaymentWithTipActivity.java

/**
 * Hooks the tip selector fragment to the payment code fragment. This causes changes in the tip
 * selector to be reflected in the payment code. This also pre-caches the payment codes so they
 * display quickly.//from  ww w.  j  a  v a  2  s .c  om
 */
private void linkTipFragmentToPaymentCode() {
    FragmentManager fm = getSupportFragmentManager();

    PaymentCodeFragment paymentCodeFragment = (PaymentCodeFragment) fm
            .findFragmentById(R.id.payment_code_fragment);

    TipSelectorFragment tipSelectorFragment = (TipSelectorFragment) fm
            .findFragmentById(R.id.tip_selector_fragment);

    /*
     * This is where the tip selector changes gets hooked to the PaymentCodeFragment. This
     * listener will be removed in onPause to break the linkage between the fragments.
     */
    tipSelectorFragment.setOnTipChangedListener(new PaymentCodeTipSelectorListener(paymentCodeFragment));

    /*
     * Pre-load the LevelUp code images so that they're ready to display before the user scrolls
     * the tip selector slider to them. Otherwise, it'd briefly show the progress spinner.
     */
    paymentCodeFragment.preCacheCodesForTips(TipSelectorFragment.ALLOWED_TIPS);
}

From source file:it.sasabz.android.sasabus.fragments.LineaFragment.java

@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
    // TODO Auto-generated method stub
    Linea linea = (Linea) list.get(position);
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction ft = fragmentManager.beginTransaction();

    Fragment fragment = fragmentManager.findFragmentById(R.id.onlinefragment);
    if (fragment != null) {
        ft.remove(fragment);//from   ww w  .  j a v a 2 s  .  co m
    }
    fragment = new DepartureFragment(bacino, linea);
    ft.add(R.id.onlinefragment, fragment);
    ft.addToBackStack(null);
    ft.commit();
    fragmentManager.executePendingTransactions();
}

From source file:com.conferenceengineer.android.iosched.ui.SearchActivity.java

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

    setContentView(R.layout.activity_search);
    mTwoPane = (findViewById(R.id.fragment_container_detail) != null);

    FragmentManager fm = getSupportFragmentManager();
    mSessionsFragment = (SessionsFragment) fm.findFragmentById(R.id.fragment_container_master);
    if (mSessionsFragment == null) {
        mSessionsFragment = new SessionsFragment();
        fm.beginTransaction().add(R.id.fragment_container_master, mSessionsFragment).commit();
    }/*from www.j a  v a 2 s  .  co m*/

    mDetailFragment = fm.findFragmentById(R.id.fragment_container_detail);

    mImageLoader = new ImageLoader(this, R.drawable.person_image_empty)
            .setMaxImageSize(getResources().getDimensionPixelSize(R.dimen.speaker_image_size))
            .setFadeInImage(UIUtils.hasHoneycombMR1());
}

From source file:io.github.waka.sevenhack.activities.MainActivity.java

@Override
public void onBackStackChanged() {
    FragmentManager fm = getSupportFragmentManager();
    Fragment current = fm.findFragmentById(R.id.content_view);
    if (current == null) {
        // no more fragments in the stack. finish.
        finish();// www  . j a v a 2s. com
    }
}

From source file:com.github.kanata3249.ffxieq.android.EquipmentSetEditActivity.java

public void notifyDatasetChanged() {
    FragmentManager fm = getSupportFragmentManager();

    {/*from ww w  .  ja  va2 s  .  com*/
        EquipmentSetEditFragment fragment = (EquipmentSetEditFragment) fm.findFragmentById(R.id.CharacterEdit);
        if (fragment != null)
            fragment.updateValues();
    }

    {
        MagicSetEditFragment fragment = (MagicSetEditFragment) fm.findFragmentById(R.id.MagicEdit);
        if (fragment != null)
            fragment.updateValues();
    }

    {
        CharacterStatusFragment fragment = (CharacterStatusFragment) fm.findFragmentById(R.id.CharacterStatus);
        if (fragment != null)
            fragment.updateValues();
    }

    {
        BasicEditFragment fragment = (BasicEditFragment) fm.findFragmentById(R.id.BasicEdit);
        if (fragment != null)
            fragment.updateValues();
    }
}

From source file:com.actionbarsherlock.sample.demos.app.LoaderCursorSupport.java

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

    FragmentManager fm = getSupportFragmentManager();

    // Create the list fragment and add it as our sole content.
    if (fm.findFragmentById(android.R.id.content) == null) {
        CursorLoaderListFragment list = new CursorLoaderListFragment();
        fm.beginTransaction().add(android.R.id.content, list).commit();
    }//from   www . j a va  2 s .c  o m
}

From source file:com.esri.android.ecologicalmarineunitexplorer.map.MapActivity.java

public void showSummary(WaterColumn waterColumn) {
    final FragmentManager fm = getSupportFragmentManager();
    SummaryFragment summaryFragment = (SummaryFragment) fm.findFragmentById(R.id.summary_container);
    if (summaryFragment == null) {
        summaryFragment = SummaryFragment.newInstance();
        mSummaryPresenter = new SummaryPresenter(summaryFragment);
    }/* w ww .  j  ava 2s .c  o m*/
    mSummaryPresenter.setWaterColumn(waterColumn);

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

    // Adjust the map's layout
    FrameLayout mapLayout = (FrameLayout) findViewById(R.id.map_container);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            0, 7);
    layoutParams.setMargins(0, 0, 36, 0);
    mapLayout.setLayoutParams(layoutParams);
    mapLayout.requestLayout();

    FrameLayout summaryLayout = (FrameLayout) findViewById(R.id.summary_container);
    summaryLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 9));
    summaryLayout.requestLayout();

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

    // Commit the transaction
    transaction.commit();

    WaterColumnFragment waterColumnFragment = (WaterColumnFragment) fm
            .findFragmentById(R.id.water_column_linear_layout_top);
    if (waterColumnFragment == null) {
        waterColumnFragment = WaterColumnFragment.newInstance();
    }
    waterColumnFragment.setWaterColumn(waterColumn);
    FragmentTransaction wcTransaction = getSupportFragmentManager().beginTransaction();
    wcTransaction.replace(R.id.column_container, waterColumnFragment);
    wcTransaction.commit();
}

From source file:can.yrt.onebusaway.ArrivalsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    UIHelp.setupActionBar(this);

    FragmentManager fm = getSupportFragmentManager();

    // Create the list fragment and add it as our sole content.
    if (fm.findFragmentById(android.R.id.content) == null) {
        ArrivalsListFragment list = new ArrivalsListFragment();
        list.setArguments(FragmentUtils.getIntentArgs(getIntent()));
        fm.beginTransaction().add(android.R.id.content, list).commit();
    }/*from   w ww  .  ja v a 2  s.  c  o  m*/
}