Search in sources :

Example 81 with FragmentManager

use of android.support.v4.app.FragmentManager in project wh-app-android by WhiteHouse.

the class MainActivity method chooseFragmentFromDrawerItem.

public void chooseFragmentFromDrawerItem(MenuItem item) {
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    Fragment f = null;
    Intent iIntent = item.getIntent();
    String feedUrl;
    mShowingLive = false;
    if (item.getGroupId() == DrawerFragment.GROUP_FAVORITES) {
        f = FeedItemListFragment.newInstance(item.getTitle(), FeedItemListFragment.TYPE_FAVORITES, null);
    } else if (iIntent != null && iIntent.getData() != null) {
        feedUrl = iIntent.getData().toString();
        switch(item.getGroupId()) {
            case DrawerFragment.GROUP_ARTICLES:
                f = FeedItemListFragment.newInstance(item.getTitle(), FeedItemListFragment.TYPE_ARTICLE, feedUrl);
                break;
            case DrawerFragment.GROUP_PHOTOS:
                f = FeedItemListFragment.newInstance(item.getTitle(), FeedItemListFragment.TYPE_PHOTOS, feedUrl);
                break;
            case DrawerFragment.GROUP_VIDEOS:
                f = FeedItemListFragment.newInstance(item.getTitle(), FeedItemListFragment.TYPE_VIDEOS, feedUrl);
                break;
            case DrawerFragment.GROUP_LIVE:
                f = FeedItemListFragment.newInstance(item.getTitle(), FeedItemListFragment.TYPE_LIVE, feedUrl);
                mShowingLive = true;
                break;
        }
    }
    if (f == null) {
        f = new Fragment();
    }
    Fragment old = fm.findFragmentByTag("contentFragment");
    if (old != null) {
        ft.remove(old);
    }
    ft.add(R.id.fragment_container, f, "contentFragment").commitAllowingStateLoss();
    decideLiveBarAndSearchVisibility();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction) Intent(android.content.Intent) BaseFragment(gov.whitehouse.app.BaseFragment) Fragment(android.support.v4.app.Fragment)

Example 82 with FragmentManager

use of android.support.v4.app.FragmentManager in project simple-stack by Zhuinden.

the class SinglePaneRoot method handleStateChange.

@Override
public void handleStateChange(StateChange stateChange, Callback completionCallback) {
    singlePaneFragmentStateChanger.handleStateChange(stateChange);
    FragmentManager fragmentManager = FragmentManagerService.get(getContext());
    Fragment fragment = fragmentManager.findFragmentById(R.id.fragment_container);
    if (fragment != null && fragment.getView() != null && fragment.getView() instanceof IsMasterView) {
        ((IsMasterView) fragment.getView()).updateSelection(stateChange.<MasterDetailPath>topNewState());
    }
    completionCallback.stateChangeComplete();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) Fragment(android.support.v4.app.Fragment) IsMasterView(com.example.stackmasterdetailfrag.application.IsMasterView)

Example 83 with FragmentManager

use of android.support.v4.app.FragmentManager in project simple-stack by Zhuinden.

the class SinglePaneRoot method onBackPressed.

@Override
public boolean onBackPressed() {
    FragmentManager fragmentManager = FragmentManagerService.get(getContext());
    Fragment fragment = fragmentManager.findFragmentById(R.id.fragment_container);
    if (fragment != null && fragment.getView() != null) {
        return BackSupport.onBackPressed(fragment.getView());
    }
    return false;
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) Fragment(android.support.v4.app.Fragment)

Example 84 with FragmentManager

use of android.support.v4.app.FragmentManager in project Rocket.Chat.Android by RocketChat.

the class AbstractFragmentActivity method onBackPress.

protected boolean onBackPress() {
    FragmentManager fragmentManager = getSupportFragmentManager();
    Fragment fragment = fragmentManager.findFragmentById(getLayoutContainerForFragment());
    if (fragment instanceof OnBackPressListener && ((OnBackPressListener) fragment).onBackPressed()) {
        return true;
    }
    if (fragmentManager.getBackStackEntryCount() > 0) {
        fragmentManager.popBackStack();
        return true;
    }
    return false;
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) Fragment(android.support.v4.app.Fragment) OnBackPressListener(chat.rocket.android.helper.OnBackPressListener)

Example 85 with FragmentManager

use of android.support.v4.app.FragmentManager in project android_frameworks_base by ResurrectionRemix.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    String path = intent.getStringExtra(EXTRA_PATH);
    if (path == null) {
        path = "";
    } else {
        // not root level, display where we are in the hierarchy
        setTitle(path);
    }
    FragmentManager fm = getSupportFragmentManager();
    if (fm.findFragmentById(android.R.id.content) == null) {
        ListFragment listFragment = new TestListFragment();
        listFragment.setListAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }));
        fm.beginTransaction().add(android.R.id.content, listFragment).commit();
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) ListFragment(android.support.v4.app.ListFragment) SimpleAdapter(android.widget.SimpleAdapter) Intent(android.content.Intent)

Aggregations

FragmentManager (android.support.v4.app.FragmentManager)293 FragmentTransaction (android.support.v4.app.FragmentTransaction)106 Fragment (android.support.v4.app.Fragment)99 View (android.view.View)53 TextView (android.widget.TextView)35 Bundle (android.os.Bundle)31 OnClickListener (android.view.View.OnClickListener)24 DialogFragment (android.support.v4.app.DialogFragment)23 Intent (android.content.Intent)20 ImageView (android.widget.ImageView)16 ScrollView (android.widget.ScrollView)14 ListFragment (android.support.v4.app.ListFragment)12 Button (android.widget.Button)11 ArrayList (java.util.ArrayList)9 FrontPageFragment (ingage.ingage20.fragments.FrontPageFragment)8 SearchResultFragment (ingage.ingage20.fragments.SearchResultFragment)8 ViewPager (android.support.v4.view.ViewPager)7 ActionBar (android.support.v7.app.ActionBar)7 RecyclerView (android.support.v7.widget.RecyclerView)7 CategoriesPageFragment (ingage.ingage20.fragments.CategoriesPageFragment)7