Java Code Examples for android.app.Fragment#getTag()
The following examples show how to use
android.app.Fragment#getTag() .
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: RxLoaderBackendNestedFragment.java From rxloader with Apache License 2.0 | 6 votes |
private String getStateId() { if (stateId != null) { return stateId; } Fragment parentFragment = getParentFragment(); stateId = parentFragment.getTag(); if (stateId == null) { int id = parentFragment.getId(); if (id > 0) { stateId = Integer.toString(id); } } if (stateId == null) { throw new IllegalStateException("Fragment dose not have a valid id"); } return stateId; }
Example 2
Source File: ExoHelper.java From buck with Apache License 2.0 | 6 votes |
/** * Try refreshing the given Fragment in place, preserving construction args. The new Fragment will * be constructed via a fresh class lookup. This method must be called from the UI thread * * @param fragment the fragment to refresh * @param preserveState if true, attempt to save the Fragment's current state and restore it to * the new instance of the fragment */ public static void refreshFragment(Fragment fragment, boolean preserveState) { assertIsUiThread(); FragmentManager manager = fragment.getFragmentManager(); final Bundle args = fragment.getArguments(); Fragment replacement = createFragment(fragment.getClass().getName(), args); String tag = fragment.getTag(); if (preserveState) { // Restore any state that's possible final SavedState savedState = manager.saveFragmentInstanceState(fragment); replacement.setInitialSavedState(savedState); } int containerViewId = ((View) fragment.getView().getParent()).getId(); final FragmentTransaction transaction = manager.beginTransaction(); transaction.remove(fragment); if (tag != null) { transaction.add(containerViewId, replacement, tag); } else { transaction.add(containerViewId, replacement); } transaction.commit(); }
Example 3
Source File: FragmentUtil.java From SmallGdufe-Android with GNU General Public License v3.0 | 5 votes |
/**清空所有除了带此tag的fragment*/ public void removeAllExcept(String tag){ FragmentTransaction ft = fm.beginTransaction(); for (Fragment f:fs) { if(f.getTag()!=null&&!f.getTag().equals(tag))ft.remove(f); } ft.commitAllowingStateLoss(); }
Example 4
Source File: ScreenView.java From snowplow-android-tracker with Apache License 2.0 | 5 votes |
public static ScreenView buildWithFragment(Fragment fragment) { String fragmentClassName = fragment.getClass().getSimpleName(); String fragmentTag = fragment.getTag(); String name = getValidName(fragmentClassName, fragmentTag); return ScreenView.builder() .activityClassName(null) .activityTag(null) .fragmentClassName(fragment.getClass().getSimpleName()) .fragmentTag(fragment.getTag()) .name(name) .type(fragmentClassName) .transitionType(null) .build(); }
Example 5
Source File: WordSearchPagerAdapter.java From Onesearch with MIT License | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { Object obj = super.instantiateItem(container, position); if (obj instanceof Fragment) { // record the fragment tag here. Fragment f = (Fragment) obj; String tag = f.getTag(); mFragmentTags.put(position, tag); } return obj; }
Example 6
Source File: LinkFragment.java From memoir with Apache License 2.0 | 4 votes |
public LinkEvent(Fragment fragment, Link link, boolean wasCancelled) { mFragmentTag = fragment.getTag(); mLink = link; mWasCancelled = wasCancelled; }
Example 7
Source File: LinkFragment.java From memoir with Apache License 2.0 | 4 votes |
public LinkEvent(Fragment fragment, Link link, boolean wasCancelled) { mFragmentTag = fragment.getTag(); mLink = link; mWasCancelled = wasCancelled; }
Example 8
Source File: FragmentCompatFramework.java From weex with Apache License 2.0 | 4 votes |
@Nullable @Override public String getTag(Fragment fragment) { return fragment.getTag(); }
Example 9
Source File: FragmentManagerHelper.java From JianshuApp with GNU General Public License v3.0 | 4 votes |
public static boolean isAdded(Fragment fragment) { // FIXME return fragment.isAdded() || fragment.getTag() != null || fragment.getId() != 0; }
Example 10
Source File: LinkFragment.java From Android-RTEditor with Apache License 2.0 | 4 votes |
public LinkEvent(Fragment fragment, Link link, boolean wasCancelled) { mFragmentTag = fragment.getTag(); mLink = link; mWasCancelled = wasCancelled; }
Example 11
Source File: FragmentCompatFramework.java From stetho with MIT License | 4 votes |
@Nullable @Override public String getTag(Fragment fragment) { return fragment.getTag(); }