Java Code Examples for android.support.v4.app.fragment#equals()
The following examples show how to use
android.support.v4.app.fragment#equals() .
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: Main2Activity.java From CoreModule with Apache License 2.0 | 6 votes |
/** * 用Fragment替换内容区 * * @param targetFragment 用来替换的Fragment */ public void changeFragment(Fragment targetFragment) { if (targetFragment.equals(currentFragment)) { return; } FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (!targetFragment.isAdded()) { transaction.add(R.id.main_body, targetFragment, targetFragment.getClass() .getName()); } if (targetFragment.isHidden()) { transaction.show(targetFragment); } if (currentFragment != null && currentFragment.isVisible()) { transaction.hide(currentFragment); } currentFragment = targetFragment; transaction.commit(); }
Example 2
Source File: AudioPlayerContainerActivity.java From VCL-Android with Apache License 2.0 | 6 votes |
public void updateLib() { if (mPreventRescan){ mPreventRescan = false; return; } FragmentManager fm = getSupportFragmentManager(); Fragment current = fm.findFragmentById(R.id.fragment_placeholder); if (current != null && current instanceof IRefreshable) ((IRefreshable) current).refresh(); else MediaLibrary.getInstance().scanMediaItems(); Fragment fragment = fm.findFragmentByTag(SidebarAdapter.SidebarEntry.ID_AUDIO); if (fragment != null && !fragment.equals(current)) { ((MediaBrowserFragment)fragment).clear(); } fragment = fm.findFragmentByTag(SidebarAdapter.SidebarEntry.ID_VIDEO); if (fragment != null && !fragment.equals(current)) { ((MediaBrowserFragment)fragment).clear(); } }
Example 3
Source File: FragmentIdHelper.java From android-task with Apache License 2.0 | 6 votes |
@SuppressLint("RestrictedApi") private static String getIndex(Fragment fragment) { String index; if (fragment.getParentFragment() != null) { index = getIndex(fragment.getParentFragment()) + "-"; } else { index = ""; } FragmentManager fragmentManager = fragment.getFragmentManager(); if (fragmentManager != null) { List<Fragment> fragments = fragmentManager.getFragments(); if (fragments != null && !fragments.isEmpty()) { for (int i = 0; i < fragments.size(); i++) { if (fragment.equals(fragments.get(i))) { index += i; break; } } } } return index; }
Example 4
Source File: FragmentPagerAdapter.java From narrate-android with Apache License 2.0 | 5 votes |
@Override public int getItemPosition(Object object) { Fragment f = (Fragment) object; for ( int i = 0; i < mOrder.length; i++ ) { if ( f.equals(mOrder[i]) ) return i; } return POSITION_NONE; }