Search in sources :

Example 96 with FragmentManager

use of android.support.v4.app.FragmentManager in project YourAppIdea by Michenux.

the class FragmentHelper method initFragment.

/**
     * @param frag
     * @param container
     * @param fm
     */
public static void initFragment(Fragment frag, int container, FragmentManager fm) {
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(container, frag);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    ft.commit();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction)

Example 97 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)

Example 98 with FragmentManager

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

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Log.d("MainActivity", "-------------------------------------------------------");
    // If we are starting afresh, start at the app list.
    final FragmentManager fm = getSupportFragmentManager();
    if (fm.findFragmentById(android.R.id.content) == null) {
        fm.beginTransaction().add(android.R.id.content, new AppListFragment()).commit();
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager)

Example 99 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 100 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)

Aggregations

FragmentManager (android.support.v4.app.FragmentManager)265 FragmentTransaction (android.support.v4.app.FragmentTransaction)98 Fragment (android.support.v4.app.Fragment)76 View (android.view.View)46 TextView (android.widget.TextView)34 OnClickListener (android.view.View.OnClickListener)24 Bundle (android.os.Bundle)23 Intent (android.content.Intent)20 ImageView (android.widget.ImageView)15 ScrollView (android.widget.ScrollView)14 DialogFragment (android.support.v4.app.DialogFragment)13 ListFragment (android.support.v4.app.ListFragment)12 Button (android.widget.Button)11 FragmentActivity (android.support.v4.app.FragmentActivity)6 ArrayList (java.util.ArrayList)6 ViewPager (android.support.v4.view.ViewPager)5 UiThreadTest (android.test.UiThreadTest)5 BackStackEntry (android.support.v4.app.FragmentManager.BackStackEntry)4 AppCompatActivity (android.support.v7.app.AppCompatActivity)4 Time (android.text.format.Time)4