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