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:de.hshannover.f4.trust.ironcontrol.view.SubscribeFragmentActivity.java

public void saveSubscribtion(View view) {
    FragmentManager fm = getSupportFragmentManager();
    Fragment tabsFragment = fm.findFragmentById(R.id.tabs_fragment);
    TabHost tabHost = (TabHost) tabsFragment.getView().findViewById(android.R.id.tabhost);

    if (tabHost.getCurrentView().getId() == R.id.tab1) {
        //Simple Subscribe
        SimpleRequestFragment fSimple = (SimpleRequestFragment) fm.findFragmentByTag(TabFragment.TAB_SIMPLE);
        fSimple.createSubscribeSaveDialog().show();

    } else if (tabHost.getCurrentView().getId() == R.id.tab2) {
        //Advanced Subscribe
        AdvancedRequestFragment fAdvanced = (AdvancedRequestFragment) fm
                .findFragmentByTag(TabFragment.TAB_ADVANCED);
        fAdvanced.createSubscribeSaveDialog().show();
    }//from w w w  .j  a  va  2 s  .c o  m
}

From source file:com.aikidonord.fragments.FragmentDate.java

@Override
/**//  ww w . ja  v  a2 s.c o m
 * Au clic sur un lment de la liste.
 */
public void onListItemClick(ListView l, View v, int position, long id) {

    String date = (String) l.getItemAtPosition(position);

    FragmentManager fm = getFragmentManager();

    if (fm.findFragmentById(R.id.fragment_prochains_stages) != null) {

        // affichage tablette
        mCallback.onDateSelected(date);

    } else {

        // dans le cas de l'affichage tlphone classique

        Intent i = new Intent(this.getActivity(), com.aikidonord.ProchainsStages.class);
        // donnes  envoyer  l'activit
        Bundle b = new Bundle();
        b.putString("type", "date");
        b.putString("data", String.valueOf(date));
        i.putExtras(b);
        this.getActivity().startActivity(i);

    }

}

From source file:com.aikidonord.fragments.FragmentLieu.java

@Override
/**/*from   w  w  w. ja va2 s .c  o m*/
 * Au clic sur un lment de la liste.
 */
public void onListItemClick(ListView l, View v, int position, long id) {

    String lieu = (String) l.getItemAtPosition(position);

    FragmentManager fm = getFragmentManager();

    if (fm.findFragmentById(R.id.fragment_prochains_stages) != null) {

        // affichage tablette
        mCallback.onLieuSelected(lieu);

    } else {

        // dans le cas de l'affichage tlphone classique

        Intent i = new Intent(this.getActivity(), com.aikidonord.ProchainsStages.class);
        // donnes  envoyer  l'activit
        Bundle b = new Bundle();
        b.putString("type", "lieu");
        b.putString("data", String.valueOf(lieu));
        i.putExtras(b);
        this.getActivity().startActivity(i);

    }

}

From source file:com.aikidonord.fragments.FragmentType.java

@Override
/**/* ww  w. j  a v a 2 s . c om*/
 * Au clic sur un lment de la liste.
 */
public void onListItemClick(ListView l, View v, int position, long id) {

    String type = (String) l.getItemAtPosition(position);

    FragmentManager fm = getFragmentManager();

    if (fm.findFragmentById(R.id.fragment_prochains_stages) != null) {

        // affichage tablette
        mCallback.onTypeSelected(type);

    } else {

        // dans le cas de l'affichage tlphone classique

        Intent i = new Intent(this.getActivity(), com.aikidonord.ProchainsStages.class);
        // donnes  envoyer  l'activit
        Bundle b = new Bundle();
        b.putString("type", "type");
        b.putString("data", String.valueOf(type));
        i.putExtras(b);
        this.getActivity().startActivity(i);

    }

}

From source file:com.example.angelina.travelapp.map.MapActivity.java

/**
 * Restore map to original size and remove
 * views associated with displaying route segments.
 * @return MapFragment - The fragment containing the map
 *//*www. j  a  va2 s .c o m*/
public final MapFragment restoreMapAndRemoveRouteDetail() {
    // Remove the route directions
    final LinearLayout layout = (LinearLayout) findViewById(R.id.route_directions_container);
    layout.setLayoutParams(new CoordinatorLayout.LayoutParams(0, 0));
    layout.requestLayout();

    // Show the map
    final FrameLayout mapLayout = (FrameLayout) findViewById(R.id.map_fragment_container);

    final CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mapLayout.setLayoutParams(layoutParams);
    mapLayout.requestLayout();

    final FragmentManager fm = getSupportFragmentManager();
    final MapFragment mapFragment = (MapFragment) fm.findFragmentById(R.id.map_fragment_container);
    mapFragment.removeRouteDetail();
    return mapFragment;
}

From source file:net.abcdroid.devfest12.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  w  w w.j  av a  2  s  .c  o m*/

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

}

From source file:de.hshannover.f4.trust.ironcontrol.view.SearchFragmentActivity.java

public void search(View view) {
    FragmentManager fm = getSupportFragmentManager();
    Fragment tabsFragment = fm.findFragmentById(R.id.tabs_fragment);
    TabHost tabHost = (TabHost) tabsFragment.getView().findViewById(android.R.id.tabhost);

    if (tabHost.getCurrentView().getId() == R.id.tab1) {
        //Simple Search
        SimpleRequestFragment fSimple = (SimpleRequestFragment) fm.findFragmentByTag(TabFragment.TAB_SIMPLE);
        fSimple.search(view);/*  www.  java2 s  .com*/

    } else if (tabHost.getCurrentView().getId() == R.id.tab2) {
        //Advanced Search
        AdvancedRequestFragment fAdvanced = (AdvancedRequestFragment) fm
                .findFragmentByTag(TabFragment.TAB_ADVANCED);
        fAdvanced.search(view);
    }
}

From source file:de.hshannover.f4.trust.ironcontrol.view.SearchFragmentActivity.java

public void saveSearch(View view) {
    FragmentManager fm = getSupportFragmentManager();
    Fragment tabsFragment = fm.findFragmentById(R.id.tabs_fragment);
    TabHost tabHost = (TabHost) tabsFragment.getView().findViewById(android.R.id.tabhost);

    if (tabHost.getCurrentView().getId() == R.id.tab1) {
        //Simple Search
        SimpleRequestFragment fSimple = (SimpleRequestFragment) fm.findFragmentByTag(TabFragment.TAB_SIMPLE);
        fSimple.createSearchSaveDialog().show();

    } else if (tabHost.getCurrentView().getId() == R.id.tab2) {
        //Advanced Search
        AdvancedRequestFragment fAdvanced = (AdvancedRequestFragment) fm
                .findFragmentByTag(TabFragment.TAB_ADVANCED);
        fAdvanced.createSearchSaveDialog().show();
    }/*  ww w . ja va  2s . c  om*/
}

From source file:com.infine.android.devoxx.ui.HomeActivity.java

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

    // TODO a virer
    // mode debug -- reset EULA
    // EulaHelper.resetEula(this);

    if (!EulaHelper.hasAcceptedEula(this)) {
        EulaHelper.showEula(false, this);
    }/*from  w ww.jav  a 2  s.  c  o m*/

    //      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(true);
    }
}

From source file:com.google.android.apps.iosched2.ui.SetupActivity.java

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

    mReceiver = new DetachableResultReceiver(new Handler());
    mReceiver.setReceiver(this);

    if (!Setup.FEATURE_MULTIEVENT_ON) {
        startActivity(new Intent(this, Setup.HomeActivityClass));
        finish();//from www .j a  v  a 2 s  . c om
        return;
    }

    checkSetup();

    setContentView(R.layout.activity_setup);
    getActivityHelper().setActionBarTitle("");

    if (Setup.FEATURE_EULA_ON) {
        if (!EulaHelper.hasAcceptedEula(this)) {
            EulaHelper.showEula(false, this);
        }
    }

    FragmentManager fm = getSupportFragmentManager();

    mSetupFragment = (SetupFragment) fm.findFragmentById(R.id.fragment_setup_dashboard);

    mSetupFragment.onSetupSelected(getApplicationContext(), new onSetupSelectedListener() {

        @Override
        public void setupSelected(Setup.EventId eventId) {

            //            Toast.makeText(getApplicationContext(), "setupSelected:" + eventId, Toast.LENGTH_SHORT).show();

            SetupHelper.setAcceptedEvent(getApplicationContext(), eventId);

            startActivity(new Intent(getApplicationContext(), Setup.HomeActivityClass));
            finish();

        }
    });

}