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.firstfbapp.MainActivity.java

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

    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    FragmentManager fm = getSupportFragmentManager();
    fragments[SPLASH] = fm.findFragmentById(R.id.splashFragment);
    fragments[SELECTION] = fm.findFragmentById(R.id.selectionFragment);
    fragments[SETTINGS] = fm.findFragmentById(R.id.userSettingsFragment);

    FragmentTransaction transaction = fm.beginTransaction();
    for (int i = 0; i < fragments.length; i++) {
        transaction.hide(fragments[i]);/*  w w w  .j  ava 2s  . c o  m*/
    }
    transaction.commit();
}

From source file:ch.corten.aha.worldclock.EditClockActivity.java

private EditClockFragment getFragment() {
    FragmentManager fm = getSupportFragmentManager();
    return (EditClockFragment) fm.findFragmentById(android.R.id.content);
}

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

/**
 * When a water column segment is tapped, show the
 * associated item in the SummaryFragment
 * @param position - index of the recycler view to display
 *///from  w w  w .jav  a2  s .com
@Override
public void onSegmentClicked(int position) {
    final FragmentManager fm = getSupportFragmentManager();
    SummaryFragment summaryFragment = (SummaryFragment) fm.findFragmentById(R.id.summary_container);
    if (summaryFragment != null) {
        summaryFragment.scrollToSummary(position);
    }
}

From source file:com.money.manager.ex.assetallocation.AssetClassEditActivity.java

private AssetClassEditFragment getFragment() {
    FragmentManager fm = getSupportFragmentManager();

    Fragment fragment = fm.findFragmentById(R.id.fragment);
    if (fragment == null)
        return null;

    return (AssetClassEditFragment) fragment;
}

From source file:com.jeffreyawest.weblogic.monitor.activity.display.DisplayServerActivity.java

@Override
public void updateDisplay(Server server) {

    super.updateDisplay(server);

    StringBuilder sb = new StringBuilder();

    if (server.getClusterName() != null && !server.getClusterName().isEmpty()
            && !server.getClusterName().equals("null")) {

        sb.append(server.getClusterName()).append(".");
    }/* w  w  w . ja v  a2s . c  om*/

    sb.append(server.getName());
    sb.append(" (").append(server.getState()).append(")");

    setTitle(sb.toString());

    String clusterName = server.getClusterName();

    if (clusterName == null || clusterName.isEmpty() || "null".equals(clusterName)) {
        clusterName = getResources().getString(R.string.n_a);
    }

    String currentMachine = server.getCurrentMachine();

    if (currentMachine == null || currentMachine.isEmpty() || "null".equals(currentMachine)) {
        currentMachine = getResources().getString(R.string.n_a);
    }

    int heapMaxMB = server.getHeapSizeMax() / Constants.ONE_MB;
    int heapFreeMB = heapMaxMB - (server.getHeapSizeCurrent() / Constants.ONE_MB);

    int heapCurrentMB = server.getHeapSizeCurrent() / Constants.ONE_MB;
    int heapCurrentUsedMB = (server.getHeapSizeCurrent() - server.getHeapFreeCurrent()) / Constants.ONE_MB;
    int heapCurrentFreeMB = server.getHeapFreeCurrent() / Constants.ONE_MB;

    TableLayout summaryTable = (TableLayout) this.findViewById(R.id.display_entity_detail_table);

    summaryTable.addView(getRow(R.string.server_name, server.getName()));
    summaryTable.addView(getRow(R.string.server_state, String.valueOf(server.getState())));
    summaryTable.addView(getRow(R.string.server_health, String.valueOf(server.getHealth())));
    summaryTable.addView(getRow(R.string.cluster_name, clusterName));
    summaryTable.addView(getRow(R.string.current_machine, currentMachine));
    summaryTable.addView(getRow(R.string.wls_version, server.getWeblogicVersion()));
    summaryTable.addView(getRow(R.string.operating_system, server.getoSName() + " " + server.getoSVersion()));
    summaryTable.addView(getRow(R.string.os_version, server.getoSVersion()));
    summaryTable.addView(getRow(R.string.jvm_version, server.getJavaVersion()));
    summaryTable.addView(getRow(R.string.open_sockets, String.valueOf(server.getOpenSocketsCurrentCount())));

    summaryTable.addView(getRow(R.string.heap_max, String.valueOf(heapMaxMB) + " MB"));
    summaryTable.addView(getRow(R.string.heap_free, String.valueOf(heapFreeMB) + " MB"));

    summaryTable.addView(getRow(R.string.heap_current, String.valueOf(heapCurrentMB) + " MB"));
    summaryTable.addView(getRow(R.string.heap_allocated_used, String.valueOf(heapCurrentUsedMB) + " MB"));
    summaryTable.addView(getRow(R.string.heap_allocated_free, String.valueOf(heapCurrentFreeMB) + " MB"));

    FragmentManager fm = getSupportFragmentManager();

    JVMCPUPieChart cpuChart = (JVMCPUPieChart) fm.findFragmentById(R.id.cpu_chart_fragment);
    cpuChart.update(server);

    JVMHeapPieChart heapChart = (JVMHeapPieChart) fm.findFragmentById(R.id.heap_chart_fragment);
    heapChart.update(server);
}

From source file:de.quist.app.maps.example.VisibleRegionDemoActivity.java

public void setMorePadding(View view) {
    if (!checkReady()) {
        return;/*from  w ww .j  ava 2s . co  m*/
    }
    FragmentManager fragmentManager = getSupportFragmentManager();
    View mapView = fragmentManager.findFragmentById(R.id.map).getView();
    int left = 150;
    int top = 0;
    int right = mapView.getWidth() / 3;
    int bottom = mapView.getHeight() / 4;
    animatePadding(left, top, right, bottom);
}

From source file:com.kinvey.scrumptious.MainActivity.java

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

    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    setContentView(R.layout.main);//from   w  ww . j  a  v a  2 s . c om

    Logger.getLogger(HttpTransport.class.getName()).setLevel(LOGGING_LEVEL);

    FragmentManager fm = getSupportFragmentManager();
    fragments[SPLASH] = fm.findFragmentById(R.id.splashFragment);
    fragments[SELECTION] = fm.findFragmentById(R.id.selectionFragment);
    fragments[SETTINGS] = fm.findFragmentById(R.id.userSettingsFragment);

    FragmentTransaction transaction = fm.beginTransaction();
    for (int i = 0; i < fragments.length; i++) {
        transaction.hide(fragments[i]);
    }
    transaction.commit();
}

From source file:com.lullabot.android.apps.iosched.ui.HomeActivity.java

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

    AnalyticsUtils.getInstance(this).trackPageView("/Home");

    setContentView(R.layout.activity_home);
    getActivityHelper().setupActionBar(null, 0);

    FragmentManager fm = getSupportFragmentManager();

    mTagStreamFragment = (TagStreamFragment) fm.findFragmentById(R.id.fragment_tag_stream);

    mSyncStatusUpdaterFragment = (SyncStatusUpdaterFragment) fm
            .findFragmentByTag(SyncStatusUpdaterFragment.TAG);
    if (mSyncStatusUpdaterFragment == null) {
        mSyncStatusUpdaterFragment = new SyncStatusUpdaterFragment();
        fm.beginTransaction().add(mSyncStatusUpdaterFragment, SyncStatusUpdaterFragment.TAG).commit();

        triggerRefresh();/*from   w ww . j a v  a  2s  .c o  m*/
    }
}

From source file:info.curtbinder.reefangel.phone.FragmentListActivity.java

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

    FragmentManager fm = getSupportFragmentManager();
    frag = getIntent().getIntExtra(FRAG_TYPE, HISTORY);

    // Create the list fragment and add it as our sole content.
    if (fm.findFragmentById(android.R.id.content) == null) {
        ListFragment list = null;//from w  w w .  j a v  a2s  .c  om
        switch (frag) {
        default:
        case HISTORY:
            list = new HistoryListFragment();
            break;
        case NOTIFICATIONS:
            list = new NotificationListFragment();
            break;
        case ERRORS:
            list = new ErrorListFragment();
            break;
        }
        fm.beginTransaction().add(android.R.id.content, list).commit();
    }
}

From source file:jp.co.conit.sss.sn.ex2.activity.SettingsActivity.java

/**
 * ????/* w  ww.  j  a va2 s. c o m*/
 * 
 * @param intent
 */
private void init(Intent intent) {

    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction transaction = fm.beginTransaction();

    SettingsFragment f = (SettingsFragment) fm.findFragmentById(R.id.frame_settings);
    if (f == null) {
        SettingsFragment fragment = SettingsFragment.newInstance();
        transaction.replace(R.id.frame_settings, fragment);
        transaction.commit();
    }
}