use of android.support.v4.app.FragmentManager in project Fragmentation by YoKeyword.
the class SupportFragment method dispatchSupportVisible.
private void dispatchSupportVisible(boolean visible) {
mIsSupportVisible = visible;
if (!mNeedDispatch) {
mNeedDispatch = true;
} else {
FragmentManager fragmentManager = getChildFragmentManager();
if (fragmentManager != null) {
List<Fragment> childFragments = fragmentManager.getFragments();
if (childFragments != null) {
for (Fragment child : childFragments) {
if (child instanceof SupportFragment && !child.isHidden() && child.getUserVisibleHint()) {
((SupportFragment) child).dispatchSupportVisible(visible);
}
}
}
}
}
if (visible) {
if (mIsFirstVisible) {
mIsFirstVisible = false;
onLazyInitView(mSaveInstanceState);
dispatchFragmentLifecycle(LifecycleHelper.LIFECYLCE_ONLAZYINITVIEW, null, false);
}
onSupportVisible();
if (_mActivity != null) {
_mActivity.setFragmentClickable(true);
}
dispatchFragmentLifecycle(LifecycleHelper.LIFECYLCE_ONSUPPORTVISIBLE, null, true);
} else {
onSupportInvisible();
dispatchFragmentLifecycle(LifecycleHelper.LIFECYLCE_ONSUPPORTINVISIBLE, null, false);
}
}
use of android.support.v4.app.FragmentManager in project Android-Developers-Samples by johnjohndoe.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FragmentManager fm = getSupportFragmentManager();
BatchStepSensorFragment fragment = (BatchStepSensorFragment) fm.findFragmentByTag(FRAGTAG);
if (fragment == null) {
FragmentTransaction transaction = fm.beginTransaction();
fragment = new BatchStepSensorFragment();
transaction.add(fragment, FRAGTAG);
transaction.commit();
}
// Use fragment as click listener for cards, but must implement correct interface
if (!(fragment instanceof OnCardClickListener)) {
throw new ClassCastException("BatchStepSensorFragment must " + "implement OnCardClickListener interface.");
}
OnCardClickListener clickListener = (OnCardClickListener) fm.findFragmentByTag(FRAGTAG);
mRetentionFragment = (StreamRetentionFragment) fm.findFragmentByTag(RETENTION_TAG);
if (mRetentionFragment == null) {
mRetentionFragment = new StreamRetentionFragment();
fm.beginTransaction().add(mRetentionFragment, RETENTION_TAG).commit();
} else {
// If the retention fragment already existed, we need to pull some state.
// pull state out
CardStreamState state = mRetentionFragment.getCardStream();
// dump it in CardStreamFragment.
mCardStreamFragment = (CardStreamFragment) fm.findFragmentById(R.id.fragment_cardstream);
mCardStreamFragment.restoreState(state, clickListener);
}
}
use of android.support.v4.app.FragmentManager in project nucleus by konmik.
the class FragmentStackTest method testFindCallback.
@UiThreadTest
public void testFindCallback() throws Exception {
FragmentManager manager = activity.getSupportFragmentManager();
FragmentStack stack = new FragmentStack(activity, manager, CONTAINER_ID);
TestFragmentC fragment = new TestFragmentC();
stack.push(fragment);
TestFragment2 fragment2 = new TestFragment2();
stack.push(fragment2);
assertEquals(fragment, stack.findCallback(fragment2, TestCallback.class));
assertEquals(activity, stack.findCallback(fragment2, Activity.class));
assertNull(stack.findCallback(fragment2, String.class));
}
use of android.support.v4.app.FragmentManager in project nucleus by konmik.
the class FragmentStackTest method testBack.
@UiThreadTest
public void testBack() throws Exception {
FragmentManager manager = activity.getSupportFragmentManager();
FragmentStack stack = new FragmentStack(activity, manager, CONTAINER_ID);
assertFalse(stack.back());
stack.push(new TestFragment1());
assertEquals(1, stack.size());
assertFalse(stack.back());
stack.push(new TestFragment1());
assertEquals(2, stack.size());
assertTrue(stack.back());
assertEquals(1, stack.size());
}
use of android.support.v4.app.FragmentManager in project Android-ObservableScrollView by ksoichiro.
the class FragmentActionBarControlListViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragmentactionbarcontrol);
FragmentManager fm = getSupportFragmentManager();
if (fm.findFragmentByTag(FragmentTransitionDefaultFragment.FRAGMENT_TAG) == null) {
FragmentTransaction ft = fm.beginTransaction();
ft.add(R.id.container, new FragmentActionBarControlListViewFragment(), FragmentActionBarControlListViewFragment.FRAGMENT_TAG);
ft.commit();
fm.executePendingTransactions();
}
}
Aggregations