Java Code Examples for android.support.v4.app.fragmentactivity#getSupportFragmentManager()
The following examples show how to use
android.support.v4.app.fragmentactivity#getSupportFragmentManager() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseMediaRouteDialogManager.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override public void openDialog() { if (mAndroidMediaRouter == null) { mDelegate.onDialogCancelled(); return; } FragmentActivity currentActivity = (FragmentActivity) ApplicationStatus.getLastTrackedFocusedActivity(); if (currentActivity == null) { mDelegate.onDialogCancelled(); return; } FragmentManager fm = currentActivity.getSupportFragmentManager(); if (fm == null) { mDelegate.onDialogCancelled(); return; } mDialogFragment = openDialogInternal(fm); if (mDialogFragment == null) { mDelegate.onDialogCancelled(); return; } }
Example 2
Source File: BaseMediaRouteDialogManager.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void openDialog() { if (mAndroidMediaRouter == null) { mDelegate.onDialogCancelled(); return; } FragmentActivity currentActivity = (FragmentActivity) ApplicationStatus.getLastTrackedFocusedActivity(); if (currentActivity == null) { mDelegate.onDialogCancelled(); return; } FragmentManager fm = currentActivity.getSupportFragmentManager(); if (fm == null) { mDelegate.onDialogCancelled(); return; } mDialogFragment = openDialogInternal(fm); if (mDialogFragment == null) { mDelegate.onDialogCancelled(); return; } }
Example 3
Source File: FragmentTabsPager.java From V.FlyoutTest with MIT License | 5 votes |
public TabsAdapter(FragmentActivity activity, TabHost tabHost, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mTabHost = tabHost; mViewPager = pager; mTabHost.setOnTabChangedListener(this); mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); }
Example 4
Source File: PermissionHandlerFactoryImp.java From PermissionAgent with Apache License 2.0 | 5 votes |
private PermissionHandler genV4Handler(@NonNull FragmentActivity fragmentActivity) { FragmentManager fragmentManager = fragmentActivity.getSupportFragmentManager(); Fragment fragment = fragmentManager.findFragmentByTag(SupportV4PermissionHandler.FRAGMENT_TAG); if (!(fragment instanceof SupportV4PermissionHandler)) { fragment = new SupportV4PermissionHandler(); fragmentManager.beginTransaction() .add(fragment, SupportV4PermissionHandler.FRAGMENT_TAG) .commitAllowingStateLoss(); } return (PermissionHandler) fragment; }
Example 5
Source File: MainActivity.java From android_tv_metro with Apache License 2.0 | 5 votes |
public TabsAdapter(FragmentActivity activity, TabHost tabHost, ViewPager pager) { super(activity.getSupportFragmentManager()); fm = activity.getSupportFragmentManager(); mContext = activity; mTabHost = tabHost; mViewPager = pager; mTabHost.setOnTabChangedListener(this); mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); }
Example 6
Source File: MessageInputToolBox.java From Android-Chat-Widget with Apache License 2.0 | 5 votes |
public MessageInputToolBox(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; FragmentActivity fragmentActivity = (FragmentActivity) context; this.fragmentManager = fragmentActivity.getSupportFragmentManager(); LayoutInflater.from(context).inflate(R.layout.message_input_tool_box, this); }
Example 7
Source File: MessageInputToolBox.java From Android-Chat-Widget with Apache License 2.0 | 5 votes |
public MessageInputToolBox(Context context) { super(context); this.context = context; FragmentActivity fragmentActivity = (FragmentActivity) context; this.fragmentManager = fragmentActivity.getSupportFragmentManager(); LayoutInflater.from(context).inflate(R.layout.message_input_tool_box, this); }
Example 8
Source File: ShiftLauncherView.java From shift with Apache License 2.0 | 5 votes |
private void addFragment(FragmentActivity activity, Fragment fragment, String tag, boolean isVisible) { FragmentManager manager = activity.getSupportFragmentManager(); Fragment oldInstance = manager.findFragmentByTag(tag); if (oldInstance == null) { FragmentTransaction transaction = manager.beginTransaction(); transaction.add(android.R.id.content, fragment, tag); if (!isVisible) { transaction.hide(fragment); } else if (tag.equals(TABS_TAG)) { manager.popBackStack(TABS_BACK_STACK, FragmentManager.POP_BACK_STACK_INCLUSIVE); transaction.addToBackStack(TABS_BACK_STACK); } transaction.commit(); } }
Example 9
Source File: PLauncher.java From YImagePicker with Apache License 2.0 | 5 votes |
private PRouterV4 getRouterFragmentV4(FragmentActivity activity) { PRouterV4 routerFragment = findRouterFragmentV4(activity); if (routerFragment == null) { routerFragment = PRouterV4.newInstance(); FragmentManager fragmentManager = activity.getSupportFragmentManager(); fragmentManager .beginTransaction() .add(routerFragment, TAG) .commitAllowingStateLoss(); fragmentManager.executePendingTransactions(); } return routerFragment; }
Example 10
Source File: FragmentHack.java From android-task with Apache License 2.0 | 5 votes |
public static FragmentManager getFragmentManager(final FragmentActivity activity) { if (Looper.myLooper() == Looper.getMainLooper()) { try { return activity.getSupportFragmentManager(); } catch (Exception e) { return null; } } else { final CountDownLatch latch = new CountDownLatch(1); final AtomicReference<FragmentManager> reference = new AtomicReference<>(); HANDLER.post(new Runnable() { @Override public void run() { reference.set(getFragmentManager(activity)); latch.countDown(); } }); try { latch.await(3, TimeUnit.SECONDS); } catch (InterruptedException ignored) { } return reference.get(); } }
Example 11
Source File: FragmentUtils.java From easygoogle with Apache License 2.0 | 5 votes |
/** * Check if an Activity already has an instance of a particular Fragment/Tag. If so, return the * existing instance. If it does not have one, add a new instance and return it. * @param activity the FragmentActivity to host the Fragment. * @param tag the Fragment tag, should be a unique string for each instance. * @param instance an instance of the desired Fragment sub-class, to add if necessary. * @param <T> a class that extends Fragment. * @return an instance of T which is added to the activity. */ public static <T extends Fragment> T getOrCreate(FragmentActivity activity, String tag, T instance) { // TODO(samstern): I'd like to avoid having to ask for an instance but I'd also like to avoid // having to create an instance using reflection... T result = null; boolean shouldAdd = false; FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment fragment = fm.findFragmentByTag(tag); if (fragment == null) { shouldAdd = true; } else { // TODO(samstern): how to be more confident about this cast? Log.d(TAG, "Found fragment instance: " + tag); result = (T) fragment; } if (shouldAdd) { Log.d(TAG, "Adding new Fragment: " + tag); // Use empty instance result = instance; ft.add(result, tag).disallowAddToBackStack().commit(); } return result; }
Example 12
Source File: SugarTask.java From SugarTask with Apache License 2.0 | 5 votes |
private void registerHookToContext(@NonNull FragmentActivity activity) { android.support.v4.app.FragmentManager manager = activity.getSupportFragmentManager(); HookSupportFragment hookSupportFragment = (HookSupportFragment) manager.findFragmentByTag(TAG_HOOK); if (hookSupportFragment == null) { hookSupportFragment = new HookSupportFragment(); manager.beginTransaction().add(hookSupportFragment, TAG_HOOK).commitAllowingStateLoss(); } }
Example 13
Source File: SugarTask.java From SugarTask with Apache License 2.0 | 5 votes |
private void unregisterHookToContext(@NonNull FragmentActivity activity) { android.support.v4.app.FragmentManager manager = activity.getSupportFragmentManager(); HookSupportFragment hookSupportFragment = (HookSupportFragment) manager.findFragmentByTag(TAG_HOOK); if (hookSupportFragment != null) { hookSupportFragment.postEnable = false; manager.beginTransaction().remove(hookSupportFragment).commitAllowingStateLoss(); } }
Example 14
Source File: VideoPagerLazyLoadActivity.java From MediaLoader with Apache License 2.0 | 4 votes |
public ViewPagerAdapter(FragmentActivity activity) { super(activity.getSupportFragmentManager()); }
Example 15
Source File: VideoGalleryActivity.java From AndroidVideoCache with Apache License 2.0 | 4 votes |
public ViewsPagerAdapter(FragmentActivity activity) { super(activity.getSupportFragmentManager()); }
Example 16
Source File: BaseFragmentModule.java From mvvm-template with GNU General Public License v3.0 | 4 votes |
@Provides @ActivityFragmentManager public FragmentManager provideActivityFragmentManager(FragmentActivity activity) { return activity.getSupportFragmentManager(); }
Example 17
Source File: ProgressDialogFragment.java From issue-reporter-android with MIT License | 4 votes |
public static boolean isShowing(FragmentActivity activity) { FragmentManager fragmentManager = activity.getSupportFragmentManager(); Fragment fragment = fragmentManager.findFragmentByTag(ProgressDialogFragment.class.getName()); return fragment != null; }
Example 18
Source File: FragmentCompatSupportLib.java From weex with Apache License 2.0 | 4 votes |
@Nullable @Override public FragmentManager getFragmentManager(FragmentActivity activity) { return activity.getSupportFragmentManager(); }
Example 19
Source File: CommonTabLayout.java From imsdk-android with MIT License | 4 votes |
/** * 关联数据支持同时切换fragments */ public void setTabData(ArrayList<CustomTabEntity> tabEntitys, FragmentActivity fa, int containerViewId, ArrayList<Fragment> fragments) { mFragmentChangeManager = new FragmentChangeManager(fa.getSupportFragmentManager(), containerViewId, fragments); setTabData(tabEntitys); }
Example 20
Source File: FragmentTabAdapter.java From guideshow with MIT License | 4 votes |
public FragmentTabAdapter(FragmentActivity a, List<SinglePage> guideContent) { super(a.getSupportFragmentManager()); mCtx = a; mGuideContent = guideContent; }