本文整理了Java中android.app.Activity.getFragmentManager()
方法的一些代码示例,展示了Activity.getFragmentManager()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.getFragmentManager()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:getFragmentManager
暂无
代码示例来源:origin: stackoverflow.com
try{
final Activity activity = (Activity) context;
// Return the fragment manager
return activity.getFragmentManager();
// If using the Support lib.
// return activity.getSupportFragmentManager();
} catch (ClassCastException e) {
Log.d(TAG, "Can't get the fragment manager with this");
}
代码示例来源:origin: commonsguy/cw-omnibus
public ContentsAdapter(Activity ctxt) {
super(ctxt.getFragmentManager());
}
代码示例来源:origin: facebook/stetho
@Nullable
@Override
public FragmentManager getFragmentManager(Activity activity) {
return activity.getFragmentManager();
}
}
代码示例来源:origin: square/leakcanary
@Override public void watchFragments(Activity activity) {
FragmentManager fragmentManager = activity.getFragmentManager();
fragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, true);
}
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings("deprecation")
@Deprecated
@NonNull
RequestManagerFragment getRequestManagerFragment(Activity activity) {
return getRequestManagerFragment(
activity.getFragmentManager(), /*parentHint=*/ null, isActivityVisible(activity));
}
代码示例来源:origin: robolectric/robolectric
private static FragmentManager buildFragmentManager(Class<? extends Activity> activityClass) {
Activity activity = Robolectric.setupActivity(activityClass);
return activity.getFragmentManager();
}
代码示例来源:origin: robolectric/robolectric
@Override
public void run() {
activityController.create(bundle).get().getFragmentManager().beginTransaction().add(contentViewId, fragment).commit();
}
});
代码示例来源:origin: wangdan/AisenWeiBo
public static void launch(Activity context) {
Fragment fragment = context.getFragmentManager().findFragmentByTag("DMColorsDialogFragment");
if (fragment != null) {
context.getFragmentManager().beginTransaction().remove(fragment).commit();
}
MDColorsDialogFragment dialogFragment = new MDColorsDialogFragment();
dialogFragment.show(context.getFragmentManager(), "DMColorsDialogFragment");
}
代码示例来源:origin: bluelinelabs/Conductor
@Nullable
private static LifecycleHandler findInActivity(@NonNull Activity activity) {
LifecycleHandler lifecycleHandler = activeLifecycleHandlers.get(activity);
if (lifecycleHandler == null) {
lifecycleHandler = (LifecycleHandler)activity.getFragmentManager().findFragmentByTag(FRAGMENT_TAG);
}
if (lifecycleHandler != null) {
lifecycleHandler.registerActivityListener(activity);
}
return lifecycleHandler;
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings({"deprecation", "DeprecatedIsStillUsed"})
@Deprecated
@Nullable
private android.app.Fragment findFragment(@NonNull View target, @NonNull Activity activity) {
tempViewToFragment.clear();
findAllFragmentsWithViews(activity.getFragmentManager(), tempViewToFragment);
android.app.Fragment result = null;
View activityRoot = activity.findViewById(android.R.id.content);
View current = target;
while (!current.equals(activityRoot)) {
result = tempViewToFragment.get(current);
if (result != null) {
break;
}
if (current.getParent() instanceof View) {
current = (View) current.getParent();
} else {
break;
}
}
tempViewToFragment.clear();
return result;
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings("deprecation")
@NonNull
public RequestManager get(@NonNull Activity activity) {
if (Util.isOnBackgroundThread()) {
return get(activity.getApplicationContext());
} else {
assertNotDestroyed(activity);
android.app.FragmentManager fm = activity.getFragmentManager();
return fragmentGet(
activity, fm, /*parentHint=*/ null, isActivityVisible(activity));
}
}
代码示例来源:origin: bluelinelabs/Conductor
@NonNull
public static LifecycleHandler install(@NonNull Activity activity) {
LifecycleHandler lifecycleHandler = findInActivity(activity);
if (lifecycleHandler == null) {
lifecycleHandler = new LifecycleHandler();
activity.getFragmentManager().beginTransaction().add(lifecycleHandler, FRAGMENT_TAG).commit();
}
lifecycleHandler.registerActivityListener(activity);
return lifecycleHandler;
}
代码示例来源:origin: Cleveroad/SlidingTutorial-Android
@Override
public void removeCurrentFragment() {
getActivity().getFragmentManager()
.beginTransaction()
.remove(TutorialFragment.this)
.commitAllowingStateLoss();
}
代码示例来源:origin: bumptech/glide
@Override
public boolean hasFragmentWithTag(String tag) {
return null != controller
.get()
.getFragmentManager()
.findFragmentByTag(RequestManagerRetriever.FRAGMENT_TAG);
}
代码示例来源:origin: bumptech/glide
public RequestManagerHarness() {
fragment = new RequestManagerFragment(lifecycle);
controller = Robolectric.buildActivity(Activity.class).create();
controller.get()
.getFragmentManager()
.beginTransaction()
.add(fragment, TAG)
.commit();
controller.get()
.getFragmentManager()
.executePendingTransactions();
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings("deprecation")
@Override
public void addFragmentWithTag(String tag, RequestManager requestManager) {
RequestManagerFragment fragment = new RequestManagerFragment();
fragment.setRequestManager(requestManager);
controller.get().getFragmentManager().beginTransaction()
.add(fragment, RequestManagerRetriever.FRAGMENT_TAG).commitAllowingStateLoss();
controller.get().getFragmentManager().executePendingTransactions();
}
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings("deprecation")
@Test
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void testDoesNotThrowIfAskedToGetManagerForFragmentPreJellyBeanMr1() {
Util.setSdkVersionInt(Build.VERSION_CODES.JELLY_BEAN);
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
android.app.Fragment fragment = new android.app.Fragment();
activity.getFragmentManager().beginTransaction().add(fragment, "test").commit();
android.app.Fragment spyFragment = Mockito.spy(fragment);
when(spyFragment.getChildFragmentManager()).thenThrow(new NoSuchMethodError());
assertNotNull(retriever.get(spyFragment));
}
代码示例来源:origin: bumptech/glide
DefaultRetrieverHarness() {
this.parent = new android.app.Fragment();
controller.create();
controller.get().getFragmentManager().beginTransaction().add(parent, PARENT_TAG)
.commitAllowingStateLoss();
controller.get().getFragmentManager().executePendingTransactions();
controller.start().resume();
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings("deprecation")
@Test
public void testCanGetRequestManagerFromFragment() {
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
android.app.Fragment fragment = new android.app.Fragment();
activity.getFragmentManager().beginTransaction().add(fragment, PARENT_TAG).commit();
activity.getFragmentManager().executePendingTransactions();
RequestManager manager = retriever.get(fragment);
assertEquals(manager, retriever.get(fragment));
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings("deprecation")
private void helpTestCanGetRequestManagerFromDetachedFragment() {
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
android.app.Fragment fragment = new android.app.Fragment();
activity.getFragmentManager().beginTransaction().add(fragment, PARENT_TAG).detach(fragment)
.commit();
activity.getFragmentManager().executePendingTransactions();
assertTrue(fragment.isDetached());
retriever.get(fragment);
}
内容来源于网络,如有侵权,请联系作者删除!