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